CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Command

  1. #1
    Join Date
    Sep 2003
    Posts
    11

    Question Command

    Hi,

    In my application I have a menu item (ID_MENUITEM) that is available on the mainframe menu as well as on the right context menu of a modeless dialog.

    I need to know when the menu item gets invoked from the mainframe versus my dialog as I need to different things on each invokation.

    Right now - whenever I have my dialog open - the dialog intercepts the WM_COMMAND message even though I am accessing the mainframe menu item.

    If I don't have the dialog open; the mainframe command runs fine.

    I am not sure what I am missing here.

    Thanks,
    MD

  2. #2
    Join Date
    May 2000
    Location
    Washington DC, USA
    Posts
    715

    Re: Command

    Why not change menu id of the dialog context menu item and the mainframe context menu item. Then there would be no way for the two to get confused with each other. Then both would have separate handlers and any common behavior could be done in separate methods which both could call...


    Its the same view, doc, and window structure using both menues so off course if the menu items have the same ID value they will end up calling the same message handler associated with that ID.

  3. #3
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Command

    Quote Originally Posted by mddd
    Right now - whenever I have my dialog open - the dialog intercepts the WM_COMMAND message even though I am accessing the mainframe menu item.
    That is impossible without altering MFC framework message routing, unless you refer to CFormView derived class as modeless dialog.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  4. #4
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Command

    Well.... as JMS says, why not make the IDs different ?

    Anyways, if you look at the MSDN, you'd see that WM_COMMAND actually has info as to whether it was invoked from a menu or not. But, thanks to MFC's ON_COMMAND, that info is not available directly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured