Context Menus

This is a discussion on Context Menus within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm an experienced programmer, but very inexperienced in programming the Win32API. I've created a context menu on a button ...

  1. #1
    Registered User Gary's Avatar
    Join Date
    Mar 2002
    Posts
    7

    Context Menus

    Hi,

    I'm an experienced programmer, but very inexperienced in programming the Win32API. I've created a context menu on a button (just for a test). I check the WM_CONTEXTMENU message to set TrackPopupMenuEx. That works great. However, when the menu pops up and I click on a command menuitem, nothing happens. Where do I trap the menu click? I tried WM_MENUSELECT and WM_COMMAND, but neither works. The funny thing is, when I change the context menu from the "button" to the main window... everything works correctly.

    Any help will be appreciated... Gary.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    If I understand you correctly, then you are creating a button and the menu is loaded with the handle of that button? If that is so, then it wont be reflected in the message proc of your window...but in the message proc of the button itself

    Please post some code as an example and we will be able to give more help

  3. #3
    Registered User Gary's Avatar
    Join Date
    Mar 2002
    Posts
    7
    Yes, the button is the owner of the context menu. Are you hinting at "subclassing" here?

    It will be very difficult to submit any code here since I'm using a GUI wrapper I'm creating to test the code. If it's absolutely essential, however, I'll create a "raw" test app for demo purposes.

    Gary.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by Gary
    Yes, the button is the owner of the context menu. Are you hinting at "subclassing" here?
    If the button is the owner of he menu, then you would probably have to subclass it to recieve its notifications........I am unsure why you would have a button actally owning a menu.......I can see no immediate gain from doing so....only complication

  5. #5
    Registered User Gary's Avatar
    Join Date
    Mar 2002
    Posts
    7
    I'm trying to provide total flexibility to the user in the win32api wrapper that I'm developing... including the ability to provide context menus for any control they might want to provide it for.

    Thanks for the tip. I'm reading the docs on subclassing and will try it soon.

    Gary.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. notifyIcon and context menus
    By fingerlickin in forum C# Programming
    Replies: 0
    Last Post: 10-14-2005, 08:48 AM
  2. Adding commands to common context menus
    By Orderbringer in forum Windows Programming
    Replies: 2
    Last Post: 04-19-2005, 07:18 PM
  3. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 08:48 PM
  4. Creating Context Menus
    By Okiesmokie in forum Windows Programming
    Replies: 1
    Last Post: 04-25-2002, 05:21 PM
  5. Context Menu, ...helper menus?
    By MrWizard in forum C++ Programming
    Replies: 3
    Last Post: 04-05-2002, 02:25 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21