How Command routing WndProc works?

When a window get a Command message through Application
Object's(CWinApp)message Q how it is routed among CView, CDocument,
CSingleDocTemplate(SDI App), CFrameWnd and CWinApp?

My concern is how the WndProc works to do command routing(Where the
information exists: lparam/wparam?) and how Application route command
message with itslef when no handlers are found with other class's of
App?

Thanks in Advance,
Raa

0
1/4/2007 6:36:04 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
957 Views

Similar Articles

[PageSpeed] 12

>When a window get a Command message through Application
>Object's(CWinApp)message Q how it is routed among CView, CDocument,
>CSingleDocTemplate(SDI App), CFrameWnd and CWinApp?

Have you had a look at the VC documentation? There's quite a bit on
this in there. Try "MFC Library Reference, Command Routing" for
starters.

Dave
0
davidl7375 (2060)
1/4/2007 9:39:26 AM
Now i understood what's happening inside WM_MESSAGES and WM_COMMANDs

1. When Message arrives Application, it route it to
AppWindow(CMyWindow). AppWindow's windowProc calls CMyWindow::OnMsg()
to map the incoming message with user defined handlers/defWindowProc.
If suppose the CMyWindow(derived from CFrameWnd) won't handle the
message, using MessageMap macros(START_MESSAGEMAP and END_MESSAGEMAP
where Framework adds when we supply our message hanlders) framework get
messageMap of next parent class(via GetMessageMap())and it goes on till
it find hanldler(till the v.base parent)if it not find then it calls
DefWindowproc().

What's FrameWork adds for this MACRO?
// In the class implementation
BEGIN_MESSAGE_MAP (CMyWindow, CFrameWnd)
    ON_WM_PAINT ()
END_MESSAGE_MAP ()

// In the class implementation
const AFX_MSGMAP* CMyWindow::GetMessageMap() const
    { return &CMyWindow::messageMap; }

const AFX_MSGMAP CMyWindow::messageMap = {
    &CFrameWnd::messageMap,
    &CMyWindow::_messageEntries[0]
};

 In Case of Command Routing, When the WindowProc of Target Window get
the command then it calls CMyWindow::OnCmdMsg instead of OnWndMsg().
Here OnCmdMsg relegate job among Document, DocumentTemplate View,
FrameWnd and App: Here's the code snippet

BOOL CFrameWnd::OnCmdMsg(...)
{
    // Pump through current view FIRST.
    CView* pView = GetActiveView();
    if (pView != NULL && pView->OnCmdMsg(...))
        return TRUE;

    // Here it will call CDocument->OnCmdMsg(...)
    // and if it fails to find handler then
    // it calls CSingle<Single/MultiDocument>Template->OnCmdMsg(...)
    // If it is MDI App then i hope CMDIChildFrame will be given
prefernces to handle the command before CMDIFrameWnd

    // Then pump through frame.
    if (CWnd::OnCmdMsg(...))
        return TRUE;


    // Last but not least, pump through application.
    CWinApp* pApp = AfxGetApp();
    if (pApp != NULL && pApp->OnCmdMsg(...))
        return TRUE;

    return FALSE;
}


NOTE - Plz add your comments about my observation!
Regards,
Raa


RajanM wrote:
> When a window get a Command message through Application
> Object's(CWinApp)message Q how it is routed among CView, CDocument,
> CSingleDocTemplate(SDI App), CFrameWnd and CWinApp?
>
> My concern is how the WndProc works to do command routing(Where the
> information exists: lparam/wparam?) and how Application route command
> message with itslef when no handlers are found with other class's of
> App?
> 
> Thanks in Advance,
> Raa

0
1/11/2007 11:53:21 AM
Reply:

Similar Artilces:

print preview command in Excel
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) I just upgraded to office 2008 for Mac and can not find the &quot;print preview&quot; command in Excel I had in my previous version and that is available in Word 2008. Was it removed? > On 11/4/09 8:43 AM, in article 59b7feef.-1@webcrossing.caR9absDaxw, <br> > &quot;sprint1005@officeformac.com&quot; wrote: <br> > <br> > > Version: 2008 <br> > > Operating System: Mac OS X 10.6 (Snow Leopard) <br> > > <br> > > I just upgraded to office ...

Will a merge work
I would like to have a single generic letter but inside this letter I need to put a list of infractions. There are only 18 infractions that can go in this letter. But you will not use all the infractions the same but need to chose one or more of these infractions and put then in the same place in the letter. Would I create the infractions in excel and do a merge? Will the merge then give you the list where you can check only the infractions that you want? Or should I be doing something different. Thanks you would create an excel template of the letter. then create a...

Outbound Mail has stopped working
Why would outbound mail all of the sudden stopped working on a MS Exchange 2000 Server. ...

ESEutil commands
I need a step by step guide on using eseutil. I need to learn how to use this tool to commit the logs to the database On Tue, 23 Nov 2004 18:09:02 -0800, "Ed" <Ed@discussions.microsoft.com> wrote: >I need a step by step guide on using eseutil. I need to learn how to use this >tool to commit the logs to the database eseutil/? A full online backup of the store will commit the logs. What exactly are you trying to accomplish? I have another site that will not have a backup solution in place until next month so i would to know how to flush the logs using this utility ...

Command Button #4
I'm trying to create a command button to clear filters in my spreadsheet. I don't know how to write the commands, but can recored a macro and run it fine. I tried pasting that macro into the button....and I had it working then messed it up. Now when I click on the button, nothing happens. The code currently associated to the button is below. I really don't want Criteria1 to = 'Reject', but the one time the button worked if no filter was set and the button clicked, an error was returned. The only way I could make it work was to force a filter as part of the macro. How...

command
how do you use command. A lot of computer people use it but how do we use it? Aaron You've reached a newsgroup dedicated to supporting the use of Microsoft Access, a relational database product. I don't see anything in your post that suggests you are asking about MS Access. Please post to a newsgroup that supports the area covered by your post. Regards Jeff Boyce Microsoft Office/Access MVP "aaron" <aaron_t_d@hotmail.com> wrote in message news:78CB1423-55B3-40A1-8BF5-D4615E816057@microsoft.com... > how do you use command. A lot of computer people use i...

CRM does not work via Internet
CRM 1.2 is not currently working via Internet. It requires a VPN connection. Is there a way to make it work on regular internet or this limitation will be addressed in the next version? Are you referring to the web client or the SFO client? The web client can be accessed publicly provided you have the appropriate ports open through your firewall (default is 80). However, there are some major security considerations to doing this. Unless you are using SSL, your company data will be being transmitted through the internet unencrypted. Due to the nature of the SFO client and it's requir...

Spellcheck Doesn't Work
Auto correct works, but the regular spellcheck does nothing, no error message, nothing Is it "turned on" . . . . Tools - Options - Spelling tab - CHECK first box "Always check spelling before sending" "Ocoee" <Ocoee@discussions.microsoft.com> wrote in message news:BEECBEDF-C157-481C-9090-11846599F9E2@microsoft.com... > Auto correct works, but the regular spellcheck does nothing, no error > message, nothing Alt + T, Options, Spelling tab, is Check spelling as I type checked? Misspelled words will be underlined. -- Ron Sommer MS MV...

XSLT example does not work?
I am trying to work the example on http://support.microsoft.com/default.aspx?scid=kb;EN-US;q315888 . I follow esxactly the advice (I beleive): Here are the files: WebForm1.aspx: -- .... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> ...

PS2007 in a VM works fine except can't get to it from the outside
While connected directly to a (VMWare) VM (similar to remote desktop connection to a physical server), I can do everything I need to do to run the client and access PWA . This (test) installation is on our public network. What "bit needs to be flipped" in order for this project server instance to be accessible through a browser on my "regular" workstation - without remote logging in to the VM directly? An IIS setting within Central Administration perhaps? I'm at a loss. Any help would be greatly appreciated. Best, Andy Novak UNT Andy: This is ...

Sort Left to Right not working
HI, ok getting a bit frustrated don't understand why this is not working: I have following info has headers in Row1 Prodgr part#, 04/04/2005 04/09/2003 04/11/2003 05/12/2005 05/22/2003 I want to sort the dates left to right so should be 04/09/2003 04/11/2003 05/22/2003 04/04/2005 05/12/2005 I did the data-->sort-->options-->left to right, but it doesn't work. Yesterday I tested and did work. FYI, the format shows General, but if I try to format as date it doesnt' do it. But if I go into the cell and hit enter then it does change the format. ...

command boxes from menu
I was working on word 2003, I had copied a portion of an online ebook to paste onto a new document, when I did right click to paste it on the doc. the command box appears outlined, no word commands, it's like a ghost. I then went to the menu at the top to Edit and find paste to do it from there and the same thing appeared; an outline of the command box, no word commands, it's like a ghost. I tried to pretend the words were there just not visible and moved my cursor to the position in which I thought paste was and clicked but nothing happened. Has anybody ever had this ...

Customize Outlook Today Not Working
in OL 2000 Customize Outlook Today button does not respond on certin workstation, any ideas? http://support.microsoft.com/?kbid=820575 might be helpful. <David.Malandra@siemens.com> wrote in message news:016b01c3c0dd$a1a6e280$a301280a@phx.gbl... > in OL 2000 Customize Outlook Today button does not respond > on certin workstation, any ideas? In article <016b01c3c0dd$a1a6e280$a301280a@phx.gbl>, David.Malandra@siemens.com says... |in OL 2000 Customize Outlook Today button does not respond |on certin workstation, any ideas? | www.google.com - you'll get about 19,000 h...

Faxes not routed through email
I have SBS 2003, following upgrades to SP2 and upgrading exchange I have lost the ability for the work stations to receive faxes by email. The router works to send the faxes to printer as they arrive and the storage mail box. If I send a fax from the work station I receive an email advising the fax has been sent successfully, but I do not receive an email when new faxes arrive! I have checked and rechecked all the settings and uninstalled and reinstalled the fax services. I have also checked that port 25 is not blocked by my Mcafee 4.5 EPO - which appears to be OK Can anyb...

Email Routing #3
The past few weeks, there have been a number of emails that were sent to the wrong people - people who were not selected to received the emails. During the summer, I upgraded our Exchange Server 2003 to 6.5.7638.1 and windows server 2003 to sp1. I installed the new version of Intelligent Message Filter. We had not had this problem before the above upgrades. I have no idea of where to start to find out why the mail is being misrouted. No event viewer problems. No error messages whatsoever. Any ideas? Is this internal or external mail? Is message tracking enabled? What does it...

Word freezes when working with pictures
When I'm making documents with many pictures, word suddenly stops working, and when i open the programmaneger there is two versions running, and the status for both is not responding?? I also have a problem running other programs when using word, the simply don't start until i close word?? Regards TeddyC It helps to know which version of Office and OS you are using and whether they are patched up to date. Start by running Detect and Repair for Office. Then go to the temp folder and clear out all the abandoned bumph: see http://www.gmayor.com/what_to_do_when_word...

windows live mail stopped working on windows 7
I have windows 7 and windows live mail. When i receive an e-mail and try to respond i get a message that says WINDOWS LIVE MAIL STOPPED WORKING. I have to try couple of times to send an e-mail. Does anyone know what can cause this problem and how to fix it? Is OS a problem? Thank you in advance. Please post the complete error message. Win 7 is not the problem. -- Ron Sommer MS MVP-Mail "Anita" <Anita@discussions.microsoft.com> wrote in message news:B5952F78-5EC0-4CA7-95A8-D535D490DE56@microsoft.com... > I have windows 7 and windows live mail. When i recei...

OWA Works in one domain name only
I am having a problem with user accessing OWA. For example users with email addresses that start as XYZ.COM have no problem, but users in the same windows domain, but in email domain ABC.COM Cannot access OWA? I changed their default email address to XYZ.COM and they can access OWA?? Is there something I need to do to allow different email domains to log on the the server You need to create additional HTTP virtual servers to support extra email domains. See 257891 or 293386 -- This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send em...

MSword File->Sendto mail recipient not working for Thunderbird in
I have installed Mozilla thunderbird as my default email client by setting in Control panel->Internet options. Now whenever i goto Msword File->sendto Mail recepients i get Thunderbird as the mail client. However in the presence of a third party com addin to office 2003(which is a menu to office) installed. Whenever I do MSword File ->Sendto Mail recepient i get Outlook started instead of Thunderbird, though in the internet options thunderbird is selected as the default still. We need to get Thunderbird as the default email client when File ->sendto is done even in th...

Routing an Excel file
We are having an issue with the routing functionality from Excel 2000. The sheet will route to the recipient fine but after the recipeint makes a change and tries to send the sheet back they get the following error Microsoft Excel General mail failure. Quit Microsoft Excel, restart the mail system, and try again. I searched the knowledge base an found Microsoft Knowledge Base Article - 168755 but this does not apply in our situation the user does not have a dialog box open. This is only happening with this particular sheet others work just fine. Please help if you can. Thanks, S...

Screenclipping not working
I'm running three sessions of ON on three computers using the Workbook stored on a USB hard drive. Two are working fine. the third does not seem to be taking the screen clipping. Screen grays and I can select but then nothing. If I clip on sys 1 0r 2 and then syc, the clipping shows up in the right place on 3. I use a note book "Stuff to File" to store clippings and screen prints. Send to ON works on sys 3. Any Ideas?? Bob Perry wrote: > I'm running three sessions of ON on three computers using the > Workbook stored on a USB hard drive. Two ...

out of office assistant not working
hi.. i have set out of office assistant from the EXCHANGE SERVER2000and from the client side outlook too..but its still not working,when i sent an e-mail locally.it does not says the person is not in the office.it goes to the inbox.. any ideas ...

regression lines and r-square in work sheets instead of charts
1. I am mathematically challenged 2. I have a series of numbers such as sales per month for a 60 month period. From these numbers I have to predict the next month, quarter’s sales. I have to (1) enter the historic data, (2) prepare a line graph, (3) add a trend line by choosing one of the regression types (4) set the period and ask for the r-square value, (5)"zoom in" on the graph to find the value. (6) go back to the worksheet and plug in the predicted number and the r-square value and (7) repeat steps 2-6 for each of the remaining 5 regression models. 3. I could enter the ...

UpdateData not working
I have a dialog with an edit control IDC_EDIT. I have associated a CString variable m_str with the edit control, via class wizard. I also have overridden the function OnOk() as follows: void CMyDialog::OnOK() { int startTime = m_startTimeEdit.m_time; int endTime = m_endTimeEdit.m_time; UpdateData(); // newStr is a public member of CMyDialog class newStr = m_str; CDialog::OnOK(); } When I call this dialog via DoModal(), i expect newStr to contain the contents of the edit control (updated contents if the control was modified). But I am observing that m_str and hence newStr still contai...

command
still learning of the sql command HOW TO DISABLE XP_CMDSHELL AND DISABLE BOTH MAIL PROCEDURES ...