#include <mgui/command.h>
Public Member Functions | |
| COMMAND_ROUTER () | |
| bool | RouteCommandMessage (UINT nID, int nCode, void *pExtra, AFX_CMDHANDLERINFO *pHandlerInfo) |
| ~COMMAND_ROUTER () | |
To make a window into a command router so that command targets can be contained in it, perform the following steps:
1. Add a COMMAND_ROUTER member to your class.
2. Override the MFC OnCmdMsg() method (inherited from CCmdTarget).
3. (Optional) Add a cast operator from your MFC class to COMMAND_ROUTER*.
For example, if your window is derived from CView, your class will look like:
class MYVIEW : public CView { public: ... operator COMMAND_ROUTER* ( ) const { return (&m_CmdRouter); } virtual BOOL OnCmdMsg (UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); ... private ... COMMAND_ROUTER m_CmdRouter; ... };
4. Implement OnCmdMsg() as follows (assuming class named MYVIEW as above).
// [Virtual] Dynamically route command messages to targets. BOOL MYVIEW::OnCmdMsg ( UINT nID, // Command ID int nCode, // Notification code void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo ) { // Attempt to have command router handle the message. if (m_CmdRouter.RouteCommandMessage(nID,nCode,pExtra,pHandlerInfo)) return (TRUE); // If we didn't process the command, call the base class // version of OnCmdMsg so the message-map can handle the message return (CView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)); }
Note: If you're creating a dialog with MGUI::DLG, all this has already been done for you. An MGUI::DLG has an COMMAND_ROUTER and a cast operator to return a pointer to it.
Note: For the X version, the COMMAND_ROUTER doesn't really do anything. It exists in X for two reasons. 1. To make the X code the same as the MFC code to avoid ugly #ifdefs 2. Could add an UpdateUI method that would call the OnUpdateUI of all COMMAND_TARGETS.
Definition at line 403 of file command.h.
|
|
Constructor.
|
|
|
Destructor.
|
|
||||||||||||||||||||
|
Route command message (MFC only). This must be called by override of OnCmdMsg() in any class which supports command routing.
|
1.3.8-20040913