MGUI::COMMAND_ROUTER Class Reference

Command Router class. More...

#include <mgui/command.h>

List of all members.

Public Member Functions

 COMMAND_ROUTER ()
bool RouteCommandMessage (UINT nID, int nCode, void *pExtra, AFX_CMDHANDLERINFO *pHandlerInfo)
 ~COMMAND_ROUTER ()


Detailed Description

Command Router class.

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 Documentation

MGUI::COMMAND_ROUTER::COMMAND_ROUTER  ) 
 

Constructor.

MGUI::COMMAND_ROUTER::~COMMAND_ROUTER  ) 
 

Destructor.


Member Function Documentation

bool MGUI::COMMAND_ROUTER::RouteCommandMessage UINT  nID,
int  nCode,
void *  pExtra,
AFX_CMDHANDLERINFO *  pHandlerInfo
 

Route command message (MFC only).

This must be called by override of OnCmdMsg() in any class which supports command routing.

Returns:
'true' if message handled, 'false' if not.


The documentation for this class was generated from the following file:
Generated on Tue Dec 14 13:20:44 2004 for TNTsdk by  doxygen 1.3.8-20040913