-
April 1st, 2014, 09:34 AM
#1
Overridden CWinApp::OnFileOpen() handler
Hello,
I am working on an existing project and noticed some interesting phenomenon. I then created a small project and reproduced this behavior.
When I created a new project, the system provided a default message handler for the file open menu item like this:
...
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
...
Then I added an message handler in CMainFrame class:
...
ON_COMMAND(ID_FILE_OPEN, &CMainFrame::OnFileOpen)
...
void CMainFrame::OnFileOpen()
{
::AfxMessageBox(_T("Hello Open"));
}
Now when I click the menu item "File"->"Open", the new added handler in CMainFrame is called.
My question is: How does CWinApp::OnFileOpen() get overridden? How does the framework know CMainFrame::OnFileOpen() should be called in stead of CWinApp::OnFileOpen()?
Another question is: Does MFC support multiple handlers for one message? How do we avoid conflicting behaviors?
Thanks,
Brian
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|