ignore WM_MOUSEMOVE msg on menu

This is a discussion on ignore WM_MOUSEMOVE msg on menu within the Windows Programming forums, part of the Platform Specific Boards category; Ok, in my simple pong game I allow the user to use the mouse as a method of input. I ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    380

    ignore WM_MOUSEMOVE msg on menu

    Ok, in my simple pong game I allow the user to use the mouse as a method of input. I simply use player.y = HIWORD(lParam). My program also has a menu and when accessing the menu, I think it generates a WM_MOUSEMOVE message. This causes player.y to use the new y-coordinate. It also happens when using the keyboard to access the menu. How do I ignore a WM_MOUSEMOVE message when it is generated by a menu?
    Don't you dare hit me on the head, you know I'm not normal.
    A Stooge Site
    Green Frog Software

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Use a variable to track menu activation and set that variable in response to a WM_ENTERMENULOOP message and reset it in response to a WM_EXITMENULOOP message. By testing the menu state variable in response to a WM_MOUSEMOVE you can exclude any such messages that seem to be generated due to menu activation. Something like (for your wndproc):
    Code:
    static BOOL bMenuState;
    switch (uMsg)
      {
      case WM_ENTERMENULOOP:
      case WM_EXITMENULOOP:
        bMenuState=!bMenuState;
        return 0;
      case WM_MOUSEMOVE:
        if (bMenuState==FALSE)
          {
           /* do pong stuff */
          }
        return 0;
      }
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Replies: 2
    Last Post: 03-05-2009, 09:25 AM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM

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