MFC Programming Hints
Last updated Nov 29, 2000
If AppWizard created your MFC application, you will have "Untitled-classname" on your title bar. To change the "Untitled" go to your *Doc.cpp. There is a routine called "OnNewDocument". Before you call the CDocument::OnNewDocument put the line
SetTitle("My new title");
This will change the titlebar to "My new title - classname."
If you don't want the "Untitled -" at all, you need to do the following. Go to your MainFrame class and override the PreCreateWindow function. You need the following in it:
cs.style &= ~FWS_ADDTOTITLE ;
Don't forget, you need to call CFrameWnd::PreCreateWindow at the end of this function.
Previously, for Win3.1, an application could check it's hPrevInstance variable to see if the application is already running. That no longer works for Win95. A good way to do this now is to look for your window name.
FindWindow (window-name, NULL)
If that returns NULL, the program is not running. Otherwise, it will return the handle to the window of the other program.
Programming Windows With Mfc (Second Ed) by Jeff Prosise Microsoft Press, 1999, ISBN#1-57-231695-0 Order from Amazon.com |
|
MFC Internals by George Shepherd Addison-Wesley Pub Co, 1996, ISBN#1-201-40721-3 More information from the Authors Order from Amazon.com |