• Welcome to Valhalla Legends Archive.
 

Getting the cursor position in a child window

Started by Tazo, September 23, 2007, 12:13 PM

Previous topic - Next topic

Tazo

The mouse coordinates within a child window are different than those of the screen. GetCursorPos returns the cursor position on the screen, which unfortunately isn't what I need. Is it possible to grab the mouse coordinates as determined by the child/parent target window? For example, when I use Spy++ to track WM_LBUTTONDOWN/UP events, they are 400,300 in the child window, but when using GetCursorPos, hovering over the same point returns 400,375. The coordinates I'm attempting to grab are not within the actual program (I do have hWnds of the child/parent target windows, though).

Barabajagal

Can't you use SendMessage WM_MOUSEMOVE to detect where the mouse is on a given window handle?

MyndFyre

Have you considered using the MapWindowPoints function?


MapWindowPoints(hwndChild, NULL, &pt, 1);


Alternatively you can also use ClientToScreen.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Tazo

Quote from: MyndFyre[vL] on September 23, 2007, 06:26 PM
Have you considered using the MapWindowPoints function?


MapWindowPoints(hwndChild, NULL, &pt, 1);


Alternatively you can also use ClientToScreen.
Thanks a lot Mynd  :)
Although you had what I wanted to do backwards, it still worked fine :P. Rather than MapWindowPoints(hwnd, NULL, &pt, 1);, I just did MapWindowPoints(NULL, hwnd, &pt, 1);. Using ScreenToClient worked fine, too.