I was trying to create a piece of code which finds a window's handle by clicking on it:

.elseif eax==IDC_GETHANDLE ;we should get the handle of the target window.
mov IsHandle,0 ;in the process of looking for a handle.
invoke SetCapture,hWnd ;captue the mouse.
invoke ShowWindow,hWnd,SW_MINIMIZE ;hiding this window.


.elseif uMsg==WM_LBUTTONDOWN

cmp IsHandle,0
jnz a1 ;if it is not equal get out.
Debg 1
invoke ReleaseCapture ;release the mouse capture:
;get the point coordinates:
mov eax,lParam
and eax,0FFFFh
mov hitpoint.x,eax
mov eax,lParam
shr eax,16
mov hitpoint.y,eax
invoke WindowFromPoint,hitpoint.x,hitpoint.y
mov THandle,eax ;save the target window handle.
invoke dwtoa,eax,addr buffer

invoke SetWindowText,HTHANDLE,addr buffer

invoke ShowWindow,hWnd,SW_SHOWDEFAULT ;show the window again.

or IsHandle,-1


However , after the window is minimized , It doesn't react for any clicks on other windows. (it should get the window visible again and write down the handle of the window I clicked on).

have a look at: http://www.codeproject.com/dialog/windowfinder.asp
that is about what I'm trying to do...

Posted on 2004-12-27 01:11:26 by realcr
SetCapture under Win32 does not work like Win16. When you move the mouse outside your app window(s) without holding down the left mouse button, the capture is lost because you leave one process and enter another.

The demo requires you to hold down a mouse button to make the capture work.
Posted on 2004-12-27 16:59:52 by tenkey