Hi,
I have a window with some controls. Now I want to detect, which control is under the mouse pointer. Using WM_MOUSEMOVE / GetCursorPos / WindowFromPoint seems not to be work.
Is there a solution without subclassing all the controls?
Best regards,
Nordwind64
Hi!
I found 2 things worthy to discuss:
1. The WM_MOUSEMOVE message gives the x,y coordinates that can be converted into a POINT structure. Why do you need the GetCursorPos function?
2. Since the controls are child windows I would try the ChildWindowFromPoint or ChildWindowFromPointEx procedures to determine the needed window handle.
I suspect that your problem could be caused by the difference between the client coordinates and the screen (absolute) coordinates.
The WM_MOUSEMOVE and the ChildWindowFromPoint uses coordinates in the client area.
Greets, Gábor
Hi,
I know, Garbor. I tried this and I tried that.
.if uMsg==WM_MOUSEMOVE
lea ebx,rect2
mov eax,lParam
and eax,00000000000000001111111111111111b
mov [ebx],eax
mov eax,lParam
and eax,11111111111111110000000000000000b
sar eax,16
mov [ebx+4],eax
lea ebx,rect2
mov eax,[ebx]
mov ebx,[ebx+4]
; PrintDec eax
; PrintDec ebx
; PrintText "---"
invoke WindowFromPoint,eax,ebx
mov erg,eax
.if eax!=0
invoke ScreenToClient,erg,addr rect2
lea ebx,rect2
mov eax,[ebx]
mov ebx,[ebx+4]
invoke ChildWindowFromPoint,erg,eax,ebx
mov erg,eax
.endif
mov eax,erg
invoke dwtoa,eax,addr unwichtig
invoke SendMessage,editcontrol,WM_SETTEXT,0,addr unwichtig
.endif
The big problem is, that WM_MOUSEMOVE only works, if mousecursor is over hwnd. If the cursor is over a child control, WM_MOUSEMOVE is not send...
Is there another way (without WM_TIMER!)?
Best regards,
Nordwind64
I think you can do that with a mouse hook similar to Iczelion's Tutorial 24, but all you would need is a local hook, so you could avoid the overhead of a global hook.
Thank you MichaelW,
I think, that is what I was looking for :U
Best regards,
Nordwind64
Quote from: Nordwind64 on January 25, 2006, 09:57:24 PM
I want to detect, which control is under the mouse pointer.
When?
This is an important question. If you want to have a textbox updating the current control then a mouse hook or timer is probably the best way to go. If you're drawing custom buttons (ie. highlight when the mouse is over) it's simply a matter of slotting the API calls in there.
Hi,
yes, I wanted to update a textbox to build a global tooltip-control.
I got it now without mouse hook, because I've build my own WM_MOUSEMOVE via GetCursorPos and variables. Works fine.
Best regards,
Nordwind64