|
Hi:
Who knows how to judge a dialog is a "File Open" dialog. When I hook the message and capture the WM_INITDIALOG, but I can not kown if the dialog is CFileDialog
Thanks
wq1976
|
|
|
|
|
If you can get a pointer to the dialog (either a CWnd* or a CDialog*) then try this:
if (pWnd->IsKindOf(RUNTIME_CLASS(CFileDialog))
// Is a CFileDialog
else
// Is not a CFileDialog
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Hi:
Recently I study the richeditctrl.I find I can not load the data of object which is in rictedit. For example, If I drop a bitmap into the richedit and modify it in richedit, but I don't have way to load the modified object out and saved it as a bmp file. Who knows?
Thanks
wq1976
|
|
|
|
|
Hi:
Recently I study the richeditctrl.I find I can not load the data of object which is in rictedit. For example, If I drop a bitmap into the richedit and modify it in richedit, but I don't have way to load the modified object out and saved it as a bmp file. Who knows?
Thanks
wq1976
|
|
|
|
|
hi all,
i would like to know how i can kill a thread created by AfxBeginThread(). i tried to use TerminateThread() to kill it. i can compile it but i can't kill.
the code is following,
//begin thread
hThread = AfxBeginThread(receiver, msg);
...
...
//kill thread
DWORD exitcode;
hThread = TerminateThread(hThread, exitcode);
it just don't work... how to do?
i know i can use CWinThread's member function to kill it. but, it make me need so much times to reconstruct my code... do i must do it to solve the problem?
regards,
|
|
|
|
|
Forget about TerminateThread. The following is the excerpt from SDK docs:
"TerminateThread is a dangerous function that should only be used in the most extreme cases.
TerminateThread can result in the following problems:
If the target thread owns a critical section, the critical section will not be released.
If the target thread is executing certain kernel32 calls when it is terminated, the kernel32 state for the thread's process could be inconsistent.
If the target thread is manipulating the global state of a shared DLL, the state of the DLL could be destroyed, affecting other users of the DLL."
You need some form of inter-thread communication to avoid the problems with TerminateThread. The easiest solution is to use a volatile boolean variable set initially to false. Main thread sets the flag to true and calls WaitForSingleObject with worker handle when it wants to end the worker. Worker periodically reads the flag and exits if flag is true.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I tried changing the font in an SDI app but when I type, the font appears with spaces in between the characters. When I highlight the text, the spaces disappear. Any idea what might be causing this behavior and how I can change it? Thanks in advance
--
Peace,
Amit Jain
|
|
|
|
|
|
My bad, should have done that first... It's an SDI application, in C_Doc::OnNewDocument, I have the following:
CFont font;
font.CreatePointFont(120, "Courier New");
((CEditView*)m_viewList.GetHead())->SetFont(&font);
--
Peace,
Amit Jain
|
|
|
|
|
Your CFont variable (and GDI font) is destroyed when it gets out of the scope. Edit control uses invalid handle for painting. Make CFont a document or view data member.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Sweet Jesus I'm bad at this ^^;;
Thanks!
--
Peace,
Amit Jain
|
|
|
|
|
Has anyone implemented a splash screen for a WTL application (or know of an available example)?
There are plenty of MFC based sample available, but I have yet to see a good WTL implementation.
-Joe
|
|
|
|
|
The GetBuffer() solution works fine for GetDlgItemText(...) & GetWindowText( LPTSTR str, int n), but I still don't understand why passing a CString to GetWindowText( CString &rString )doesn't work.
Any ideas?
|
|
|
|
|
GetWindowText is a member of CWindow, which is an ATL class that doesn't know anything about WTL's CString.
CodeGuy
http://groups.yahoo.com/group/wtl
|
|
|
|
|
Hello,
I am using MFC to add an icon on a button. If I use the standard target device(32*32). The icon can show normally on the button. But If I use other target devices or customed target devices ( such as 64*16 ). The icon will fit into 32*32 automatically. So the icon will change and become ugly. If I use resource to add several target devices in the same icon. Add delete the image on the standard device (32*32). Then the icon will not display on the button at all. Who can tell me the reason and how to display the icon with 64*16 target device? Thanks in advance. The following is my code to link the icon with my button.
HICON hIcon;
hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_WALK));
((CButton*)GetDlgItem(IDC_Walk))->SetIcon( hIcon );
Kidd
|
|
|
|
|
>>>
HICON hIcon;
hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));
((CButton*)GetDlgItem(IDC_MY_BUTTON))->SetIcon( hIcon );
<<<
LoadImage() should do the trick for you;
HICON hIcon;
hIcon = (HICON)::LoadImage ( AfxGetResourceHandle(),
MAKEINTRESOURCE ( IDR_MAINFRAME ), IMAGE_ICON, 64, 16, LR_DEFAULTCOLOR );
m_wndMyButton.SetIcon ( hIcon );
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Thanx a lot. It worked
Kidd
|
|
|
|
|
Hello. Can anybody tell me how-to add a icon to control listbox in MFC?
Thanks,
Caleb
|
|
|
|
|
Use a CComboBoxEx instead, which has built-in support for images.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
You have two options:
1) use owner-draw. In this scenario you're responsible for drawing listbox items; you can draw text, icons, whatever you want
2) switch to CListCtrl. This control can display item images.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
I have a class used to create a member varible within another class.
The problem is I can't pass values to the constructor as parameters, from the header file.
How do you normally deal with this scenario?
Cheers
Richard
|
|
|
|
|
I think this is what you mean
Class A is a member variable of class B, and requires an int. I cannot do this inside my constructor:
{
m_A(12);
}
What I *can* do is this
B::B(char * pChar) : m_A(12)
By putting a colon and then listing the variable that needs values in it's constructor, the problem is solved.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Hi,
I would like to create a bitmap, eventually to be saved onto disk. This is going to be a composite of two other bitmaps, placed side by side.
Can some one point me in the right direction of suitable functions and any issues involved.
Cheers
Richard
|
|
|
|
|
Saving to disk requires GDI+ or an external library. Other than that, it's just a case of creating a bitmap big enough and drawing the two other bitmaps onto it.
Oh, and you'll have trouble if you use DDB's ( i.e. CBitmap ) and the two images are different bit depths to each other or the target image. I suggest if you don't use GDI+ you use a DIBSection wrapper, like the one found here on CP.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
I've had a problem with Visual C 6 for a while now where the debugger freezes after a certain point in the program.
For example. I set a break point somewhere in the program - say a method thats called when the use clicks on a button - when I click on the button the program freezes, and so does VisualC. I've tried leaving it like this overnight (maybe it was just being slow...) and it made no difference.
However it sometimes, albeit rarely, works.
I've tried re-installing service pack 6 and the same happens. I've tried reinstalling VisualC and the same happens, I've even tried reinstalling Windows (going from 98 to 2000) and the same happens.
Oh, it doesn't seem to happen with all projects. It seems to only happen with largish projects. With my current project, and with the VisualStudioDemo project (part of the BCGControlBar library), but not with a simple dialog demo.
Any ideas on how to solve this?
Thanks
Duncan Strand
www.zebs.org.uk
(Win2000 sp2, VC6 sp5)
|
|
|
|