The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: RHL on April 05, 2012, 05:51:48 AM

Title: how to know information of a control?
Post by: RHL on April 05, 2012, 05:51:48 AM
I want to know as know the position of a control ( the X,Y coordinates ).
also I want know the height and widht properties
API to use?
Title: Re: how to know information of a control?
Post by: dedndave on April 05, 2012, 06:14:40 AM
we usually use GetWindowRect
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519%28v=vs.85%29.aspx

it returns a RECT
        .DATA?

rc      RECT <>

        .CODE

        INVOKE  GetWindowRect,hWindow,offset rc
        mov     ecx,rc.right
        mov     edx,rc.bottom
        sub     ecx,rc.left
        sub     edx,rc.top

;ECX = width
;EDX = height


if it is the top window, the RECT values are screen coordinates
if it is a child window, the RECT values are client coordinates

you can use the function for all types of windows - buttons, etc
i don't think it works for menus, though
Title: Re: how to know information of a control?
Post by: MichaelW on April 05, 2012, 06:22:10 AM
Another possibility is  GetWindowInfo (http://msdn.microsoft.com/en-us/library/windows/desktop/ms633516(v=vs.85).aspx), although I don't recall ever testing it on a child window.

And for some purposes  GetClientRect (http://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx) might be useful.
Title: Re: how to know information of a control?
Post by: RHL on April 05, 2012, 06:32:36 AM
thanks u dedndave,MichaelW  :green
Title: Re: how to know information of a control?
Post by: dedndave on April 05, 2012, 06:35:58 AM
a couple more functions that come in handy...

ClientToScreen
http://msdn.microsoft.com/en-us/library/dd183434%28v=vs.85%29.aspx

ScreenToClient
http://msdn.microsoft.com/en-us/library/dd162952%28v=vs.85%29.aspx