The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: realcr on December 30, 2004, 09:17:52 PM

Title: Control handle by point inside dialog
Post by: realcr on December 30, 2004, 09:17:52 PM
Is there a way to get a control's handle which is inside a dialog by its relative location in the dialog?
I have seen WindowFromPoint , however this function works only if the window is on the top of the Z axis.
Is there another way to do it?

bar.
Title: Re: Control handle by point inside dialog
Post by: jimh on December 30, 2004, 11:36:02 PM
As far as I can tell by a quickie applet I threw together, WindowFromPoint works even if a window/control is at the bottom of the Z-Order. I found the hWnd of several different windows/controls with Spy++ (a VS tool) and then used my mouse hovering applet to view the same window and I consistently got the same hWnd.


// C Code...
POINT pt;
if( GetCursorPos(&pt) )
hWndCurrentPoint = WindowFromPoint( pt );


If you have a more specific example on when WindowFromPoint might not work, post it and I'll take a look.

Jim
Title: Re: Control handle by point inside dialog
Post by: realcr on December 31, 2004, 01:24:52 PM
OK tnx for the advice Jimh.

Bar.
Title: Re: Control handle by point inside dialog
Post by: donkey on December 31, 2004, 01:39:52 PM
Hi,

There is also a ChildWindowFromPoint function for child windows. The point must be converted to client coordinates, that is relative to the upper left corner of the parents client area...

invoke GetCursorPos, offset pt
invoke ScreenToClient, [hParent], offset pt
invoke ChildWindowFromPoint, [hParent], offset pt
Title: Re: Control handle by point inside dialog
Post by: realcr on January 01, 2005, 12:17:15 PM
Tnx , that was excatly what I was looking for donkey.

bar.