Tracking the mouse on menu items

This is a discussion on Tracking the mouse on menu items within the Windows Programming forums, part of the Platform Specific Boards category; Hello, In Solitaire, when you hover over the menu items, a string is displayed at the bottom of the window. ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    43

    Tracking the mouse on menu items

    Hello,

    In Solitaire, when you hover over the menu items, a string is displayed at the bottom of the window. I'm trying to recreate this feature in a similar card game of mine, but I can't seem to find an efficient way to detect mouse movement in menus.

    I've tried using the WM_NCMOUSEMOVE notification and checking whether the wParam is equal to HTMENU, but that would be tedious as I would have to calculate the position of each menu item.

    Is there any other way to achieve this?

    Thanks.

  2. #2
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    Solitare uses a status bar. If I recall correctly, status bars and menu items work pretty well together. It doesn't take that much effort to get the status bar to update when your mouse is over a menu item.
    Don't quote me on that... ...seriously

  3. #3
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    I can think of two methods to accomplish this, both seem a bit ineffecient to though:

    1) Use GetMenuState to constantly check which of your menuitems is currently highlighted, then take appropriate action.

    2) Use MenuItemFromPoint in conjunction with GetCursorPos and constantly check if the cursor is located on a menuitem, and take appropriate action.

    I'd say #1 is more effecient (if it could be called that...) but it only checks for highlighting, whereas #2 checks if the cursor is over a menuitem (regardless of whether it is highlighted or not).

  4. #4
    Registered User
    Join Date
    Dec 2005
    Posts
    43
    Ah right, I forgot about status bars (I was drawing a filled RECT). I found this function, which does exactly what I want (and is easily adaptable to string tables!)

    Thanks for the help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  2. HELP!!!!emergency Problem~expert please help
    By unknowppl in forum C++ Programming
    Replies: 9
    Last Post: 08-21-2008, 07:41 PM
  3. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 08:35 AM
  4. Problem with Mouse Over Menu!!! HELP!!!
    By SweeLeen in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2006, 02:10 AM
  5. Best "Menu" method?
    By SSJMetroid in forum Game Programming
    Replies: 11
    Last Post: 12-08-2005, 12:05 AM

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