|
In a file I see:
BEGIN_MESSAGE_MAP(CPaletteStatusBar, CStatusBar)
ON_WM_CREATE()
ON_WM_SIZE()
END_MESSAGE_MAP()
What does ON_WM_CREATE() mean? WHat is VC doing by writing this line of code?
Appreciate your help,
ns
|
|
|
|
|
ON_WM_CREATE() basically ties the WM_CREATE message to a member function of the CPaletteStatusBar called OnCreate. So whenever the WM_CREATE message is sent to the window tied to an instance of the CPaletteStatusBar class, OnCreate is called with the proper paremeter.
Having said that, here's what I typically do when I need to find the answer to a question such as yours:
1. Look it up on MSDN to see if that can answer my question.
2. If MSDN is not enough, I search for it in the actual MFC code. In other words, I do a Find in Files of ON_WM_CREATE and tell it to search in the folder where the MFC source code is installed (ie, C:\Program Files\Microsoft Visual Studio\VC98\mfc).
3. If I still don't understand, I try to find someone around me that knows the answer.
4. If that still doesn't work, I come to CodeProject and ask.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Thanks. I havent programmed in a while and am feeling extremely overwhelmed. SO I am not functioning at my best. Sorry to bother you. YOur ideas are the first in this round that I'l take to heart....
Appreciate your help,
ns
|
|
|
|
|
Just one thing though: (hope I am not being a pain...)
THe search in the MFC folder gave me a zillion cpp files and I didnt know which one might be the relevant one and couldnt really go through each one. How does one decide?
I couldnt figure out even after seeing MSDN when WM_CREATE Is issued: It says
The WM_CREATE message is sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function.
SO if I dont have a call to CreateWindow I dont see this message? So when I call Create, this messgae isnt issued?
Appreciate your help,
ns
|
|
|
|
|
WM_CREATE is sent to the window by Windows (not MFC) as the first message after the window is created by the operating system.
WM_CREATE message is usually used by applications to perform window initializations after it has been created.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
ns wrote:
SO if I dont have a call to CreateWindow I dont see this message? So when I call Create, this messgae isnt issued?
Every window that is created in your application will call CreateWindow or CreateWindowEx and WM_CREATE will be sent. MFC hides the details of this in many ways, but in the long run CreateWindowEx or CreateWindow will be called.
John
|
|
|
|
|
May I suggest , that you try to use F12 (go to definition), it is really helpful if you want to see where class/variable/macro/function defined and what it does.
|
|
|
|
|
I have to have a Create function to spawn my modeless dialog. Do I just write it in or do I make it trap the WM_CREATE message?
Appreciate your help,
ns
|
|
|
|
|
The code I'm looking at has:
BOOL CZoom::Create(UINT nID, CWnd *pWnd, int index)
{
m_imageMapIndex = index;
m_imagePtr = imageMap[index].GetImagePointer();
m_imageSize = imageMap[index].GetImageSize();
imageMap[index].IncrementPointerCount();
imageMap[index].pZoomSet.insert(this);
return CDialog::Create( nID,pWnd);
}
and
void CResizeSonarViewBoxView::OnCreateviewbox()
{
CImageDisplay* pdlg;
pdlg = new CImageDisplay();
if(pdlg != NULL)
{
BOOL ret = pdlg->Create(IDD_DIALOGIMAGEDISPLAY, this);
if(!ret)
AfxMessageBox("Error creating Dialog");
}
so I guess my question is that did they just go and add a Create() function by hand or did they get it through he classWizard by trapping WM_CREATE and modify it?
In yet another book I see that they dont add a Create function by hand, but just call it in the constructor like so:
Create(IDD,pPArent);
Where did this function come from? Its not in their code......
Can I infer that if I want my create() to do more stuff, I can modify it, but then I have to write my own Create()?
Again is Create() associated with WM_CREATE ?
Thanks
Appreciate your help,
ns
|
|
|
|
|
Create is just a member function of the CDialog class. It has nothing to do with the WM_CREATE message. It's just the one used to create the dialog box modelessly.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Thank you..
But now I'm curious. WHats WM_CREATE all about? When is it sent out? BY whom? ANd who gets it and how to they respond when they get it?
Appreciate your help,
ns
|
|
|
|
|
Use MSDN to fully answer some of these questions, but I also suggest picking up a book about Windows programming.
Here's what I know:
Whenever a window is created, resized, clicked on, destroyed, whatever, Windows (the operating system) sends a corresponding message to the callback function tied to it (the window). WM_CREATE is the ID of the message sent to that function (by Windows) at the moment the window is being created. If the programmer needs to do something at that time, he checks for that message (inside the function) and does something. If he doesn't care about it, he doesn't do anything and the window continues being created.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Recommend any super duper good book?
Appreciate your help,
ns
|
|
|
|
|
I don't have anything off the top of my head. I've heard that Charles Petzold puts out great Windows programming books. You may search him out on the web.
Also, you may wanna do a Search on this forum, or the Lounge maybe to see what other people have recommended. I'm sure this question (what book do you recommend?) has been asked many times here before.
Good luck and don't worry, it will all make sense before you know.
Alvaro
All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain
|
|
|
|
|
hi all, i need to make a dialog that takes over full screen,
and cannot be exited by any hot keys / ctrl-alt-delete combinations.
im going to build a pass-protected exit area of the code and make the computer autostart this program on reboot because it will be used by consumers in a store that are unsupervised, and i dont want them f***ing around in my computers.
any good suggestions on easy ways to make the dialog take full screen, and override all keyboard input to do nothing....???
todo....
:: insert inpirational text here ::
|
|
|
|
|
Think keyboard hooking function and consider MoveWindow function
to start with windows add a key in the registry under local machine\software\microsoft\window`\current version\run
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Well, that was easy enough, i got the dialog to be fullscreen.....
but now i still need to figure out how kill all hotkeys (altf4, ctrl-esc, ctrl-alt-delete, erc). i need to keep the regular typing keys actually because people will need to fill in survey information.
suggestions greatly appreciated
todo....
:: insert inpirational text here ::
|
|
|
|
|
http://msdn.microsoft.com/msdnmag/issues/02/09/CQA/default.aspx
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
that would be good ,but i want to do it programmatically, as if i do not have any access to the target computer.
also, id rather hookup a function to throw away all keyboard input except a-z and 1-9 , so that alt-f4, ctrl tab, ESC, and other escape mechanisms wont be possible, the article doesnt address the other escapes.
todo....
:: insert inpirational text here ::
|
|
|
|
|
I have an MDI project that has two views and only 1 document. View 1 spawns a number of modeless dialogs. Then I switch from view1 to view2. THee views are contained within mainframe. THe modeless windows from view 1 show up over view 2. What I need is to have view2 obscure the modeless dialogs. Then when I switch back to oview 1, I want view 1 to appear UNDER the modeless windows exactly as things were before I switched over to view 2.....
How do I do this?
Thanks
Appreciate your help,
ns
|
|
|
|
|
I have a CEdit on a dialog box that pops up from a button on a MDI MFC project. Its modeless. If I stretch this dialog, I want the window to maintain its height, but stretch horizontally. Plus I want it to wrap the text around and develop scrollbars if necessary. How do I organize this? What functions Do I need here?
Appreciate your help,
ns
|
|
|
|
|
Hi,
I am familiar with registry saving functions. However I dont know what to save here:
The main app spawns any desired number of dialogs. THe user say spawns 6 windows, sizes them, and places them in some locations on the screen. When he exits and then later starts up the program he wants the UI to come up like he left it. WIth 6 dialogs spawned , in exactly the same locations and of the same sizes as he left them. What are the settings to save and how do we get them?
1. How to get locations on screen?
2. hOw to get sizes of the dialogs?
3. Initially you have to press a menu item "Create ViewBox" to spawn the window.one click - one window ...etc.
So when the app starts up again, this time the user isnt clicking the menu 6 times. They just magically show up.
How do we get these three things done? I can svae in the registry and read from the registry but dont know what I am saving. Also after I read the variables I have saved, how do I use them to magically create the 6 (or n) dialogs? These will be a class say CViewBox associated with an IDD_DIALOG1.
Appreciate your help,
ns
|
|
|
|
|
To save
WINDOWPLACEMENT myPos;
::ZeroMemory(&myPos, sizeof(WINDOWPLACEMENT));
myPos.length = sizeof(WINDOWPLACEMENT);
if(GetWindowPlacement(hWnd, &myPos))
WritePlacementInfo(&myPos);//however you store it - disk, registry etc..
To restore
WINDOWPLACEMENT myPos;
::ZeroMemory(&myPos, sizeof(WINDOWPLACEMENT));
myPos.length = sizeof(WINDOWPLACEMENT);
if(ReadPlacementInfo(&myPos)) //read it from where you saved it
{
myPos.showCmd = (myPos.showCmd == SW_SHOWMINIMIZED)? SW_SHOWNORMAL:myPos.showCmd;
SetWindowPlacement(hWnd, &myPos);
}
|
|
|
|
|
Thanks. Did this also save the dimensions of the dialog?
Or is that another bit of information? I need to know about that too.thanks
Appreciate your help,
ns
|
|
|
|
|
Yes, see definition of WINDOWPLACEMENT and GetWindowPlacement
|
|
|
|