Retrieving mouse coordinates behind a window.

This is a discussion on Retrieving mouse coordinates behind a window. within the Windows Programming forums, part of the Platform Specific Boards category; I am currently using the lParam of the WM_MOUSEMOVE to determine where on the screen the mouse is located although ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    74

    Question Retrieving mouse coordinates behind a window.

    I am currently using the lParam of the WM_MOUSEMOVE to determine where on the screen the mouse is located although I have noticed that if another window (application) is on top of my application as my mouse moves over this area my application doesn't seem to be receiving the WM_MOUSEMOVE message anymore... atleast I think this is the problem. Is there a reason for this? How would I go about correcting it?

    Note: My application is always the active application while the other application on top of mine is inactive the whole time.

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Quote Originally Posted by Win32 API
    The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse.
    You only get WM_MOUSEMOVEs if the mouse is above your window, unless you capture the mouse. To do so, call SetCapture() and friends - this will send mouse messages to you as long as you're the foreground window, regardless of mouse location. (What exactly are you trying to do?)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    74
    Thanks mate, that sounds like it would solve my problem perfectly.

    Quote Originally Posted by MSDN
    SetCapture captures mouse input either when the mouse is over the capturing window, or when the mouse button was pressed while the mouse was over the capturing window and the button is still down.
    Quote Originally Posted by Cactus_Hugger
    (What exactly are you trying to do?)
    Click on a bitmap in my application and drag it. It will follow my mouse position until the mouse button is released. Problem was it would stop dragging when the mouse passed over another window and would not continue until my mouse reappeared on the other side of the top window. So instead of a smooth drag effect it would essentially jump over/under the top window.

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    74
    Hmm.. SetCapture() didn't work as I had hoped.

    Quote Originally Posted by Cactus_Hugger
    this will send mouse messages to you as long as you're the foreground window
    Hmm, guess I misread you. Foreground as in the topmost window in view? Or foreground as in the active app? My application is the active app the whole time while an inactive app set to ALWAYS ON TOP is on top of mine. When my mouse moves over this inactive app. my app. does not receive window messages even with SetCapture(). Any ideas?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 07:57 PM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 09:23 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  4. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 11:17 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM

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