Want Toolbar messages to go to a dialog not CMainFrame 
Author Message
 Want Toolbar messages to go to a dialog not CMainFrame

I have a toolbar which is essentially a shortcut way to activate some
functions in a modeless dialog, so I want the toolbar button message
functions to call the dialog.  However, the toolbar originally had its
messages go to CMainFrame.  When I load the class wizard, it is possible to
define message handlers for button Ids in CMainFrame, but not in the dialog.

How does the class wizard know who the button id should go to?
How can I reroute the ids to go somewhere else?

Thanks,
Andy



Sat, 31 Mar 2001 03:00:00 GMT  
 Want Toolbar messages to go to a dialog not CMainFrame
Andy

Quote:
>How does the class wizard know who the button id should go to?
>How can I reroute the ids to go somewhere else?

You can override OnCmdMsg, check to see if the dialog exists and if it
does, route the messages to that window's OnCmdMsg.  If that returns
FALSE or the dialog does not exist, route the messages to the parent
class' OnCmdMsg.

Chip

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Make it idiot-proof and someone will make a better idiot."
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Remove NO and SPAM from my email address.



Sun, 01 Apr 2001 03:00:00 GMT  
 Want Toolbar messages to go to a dialog not CMainFrame

Quote:

> I have a toolbar which is essentially a shortcut way to activate some
> functions in a modeless dialog, so I want the toolbar button message
> functions to call the dialog.  However, the toolbar originally had its
> messages go to CMainFrame.  When I load the class wizard, it is possible to
> define message handlers for button Ids in CMainFrame, but not in the dialog.

> How does the class wizard know who the button id should go to?
> How can I reroute the ids to go somewhere else?

> Thanks,
> Andy

Yes, You can definitly redirect. Your CMainFrame class inherits a member called:

OnCmdMsg. By Overriding this virtual function, you csn route all the command
messages to another window,
E.g.

BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO*
pHandlerInfo)
{
    pDialog->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);

Quote:
}

--
======================================================
****************** Tomer Petel ***********************
** UConn CS Student and Part Time Software Engineer **

************* Remove stopspam to email **************
======================================================


Tue, 03 Apr 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Send a message from a toolbar to CMainFrame

2. PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

3. toolbar buttons with combo buttons not getting ON_UPDATE_COMMAND_UI messages

4. toolbar buttons with combo buttons not getting ON_UPDATE_COMMAND_UI messages

5. variables in cmainframe and toolbar buttons

6. CMainFrame toolbar problem

7. toolbar buttons enabeld in CMainFrame class?

8. Creating own toolbar in CMainFrame

9. Creating own toolbar in CMainFrame

10. Adding a toolbar to a Dialog with ATL ( NOT MFC)

11. Adding a toolbar to a Dialog with ATL ( NOT MFC)

12. ToolBar in Dialog Box (not main frame)

 

 
Powered by phpBB® Forum Software