The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
April 22, 2018, 09:54:21 PM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  General Forums
| |-+  The Laboratory (Moderator: Mark_Larson)
| | |-+  GetWindowPos
« previous next »
Pages: [1] Print
Author Topic: GetWindowPos  (Read 5493 times)
guga
Member
****
Posts: 50



GetWindowPos
« on: May 20, 2012, 12:54:17 AM »

RosAsm Syntax

Code:

;;
    GetWindowPos v 1.0
   
    This functions retrieves the x, y, width and heigth of any window.

    Arguments:
   
        hWnd(in): A handle to the window. The window can be a child, overlapped, a dialog a control etc.
        PosStruct(out): A pointer to a WINPOS structure to rceive the values found.

    Returned Value: If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window with the WS_POPUP style, the return value is a handle to the owner window.
                    If the function fails, the return value is NULL. To get extended error information, call GetLastError.
                    This function typically fails for one of the following reasons:
                        *The window is a top-level window that is unowned or does not have the WS_POPUP style.
                        •The owner window has WS_POPUP style.

    Remarks:
        The WINPOS structure have the following format and specifications:

        [WINPOS:
         WINPOS.cx: D$ 0 ; The initial horizontal position of the window. For an overlapped or pop-up window, the x parameter is
                         ; the initial x-coordinate of the window's upper-left corner, in screen coordinates. For a child window,
                         ; x is the x-coordinate of the upper-left corner of the window relative to the upper-left corner of the
                         ; parent window's client area.

         WINPOS.cy: D$ 0 ; The initial vertical position of the window. For an overlapped or pop-up window, the y parameter is
                         ; the initial y-coordinate of the window's upper-left corner, in screen coordinates. For a child window,
                         ; y is the initial y-coordinate of the upper-left corner of the child window relative to the upper-left
                         ; corner of the parent window's client area. For a list box y is the initial y-coordinate of the upper-left
                         ; corner of the list box's client area relative to the upper-left corner of the parent window's client area.


         WINPOS.width: D$ 0 ; The width, in device units, of the window.
         WINPOS.height: D$ 0; The height, in device units, of the window.
         ]       
       

    Usage example:

    [WINPOS:
     WINPOS.cx: D$ 0
     WINPOS.cy: D$ 0
     WINPOS.width: D$ 0
     WINPOS.height: D$ 0]
   
   
    call 'USER32.GetDlgItem' D@hWnd, 156
    call GetWindowPos eax, WINPOS


    Author: Gustavo Trigueiros (aka: Beyond2000!)
    Build Date: 19/05/2012 (v 1.0)

;;


Proc GetWindowPos:
    Arguments @hWnd, @PosStruct
    Local @width, @height, @hParent
    Structure @WINDOWINFO 64, @WINDOWINFO.cbSizeDis 0,  @WINDOWINFO.rcWindow_leftDis 4,  @WINDOWINFO.rcWindow_topDis 8,
                              @WINDOWINFO.rcWindow_rightDis 12,  @WINDOWINFO.rcWindow_bottomDis 16,  @WINDOWINFO.rcClient_leftDis 20,
                              @WINDOWINFO.rcClient_topDis 24,  @WINDOWINFO.rcClient_rightDis 28,  @WINDOWINFO.rcClient_bottomDis 32,
                              @WINDOWINFO.dwStyleDis 36,  @WINDOWINFO.dwExStyleDis 40,  @WINDOWINFO.dwWindowStatusDis 44,  @WINDOWINFO.cxWindowBordersDis 48,
                              @WINDOWINFO.cyWindowBordersDis 52,  @WINDOWINFO.atomWindowTypeDis 56,  @WINDOWINFO.wCreatorVersionDis 60
    Uses esi, ecx, edx

    call 'user32.GetParent' D@hWnd
    On eax = 0, ExitP
    mov D@hParent eax
    call 'USER32.MapWindowPoints' D@hWnd, eax, D@PosStruct, 2

    call ZeroMemory D@WINDOWINFO, 64
    mov D@WINDOWINFO.cbSizeDis 64
    call 'USER32.GetWindowInfo' D@hWnd, D@WINDOWINFO
    mov esi D@PosStruct
    mov eax D@WINDOWINFO.rcWindow_rightDis | sub eax D@WINDOWINFO.rcWindow_leftDis | mov D$esi+WINPOS.widthDis eax
    mov eax D@WINDOWINFO.rcWindow_bottomDis | sub eax D@WINDOWINFO.rcWindow_topDis | mov D$esi+WINPOS.heightDis eax

    mov eax D@WINDOWINFO.cxWindowBordersDis | sub D$esi+WINPOS.cxDis eax
    mov eax D@WINDOWINFO.cyWindowBordersDis | sub D$esi+WINPOS.cyDis eax

    mov eax D@hParent

EndP

Logged

dedndave
Member
*****
Posts: 12523


Re: GetWindowPos
« Reply #1 on: May 20, 2012, 01:39:29 AM »

couldn't you use GetWindowRect ?
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519%28v=vs.85%29.aspx

also - be aware that, when a window is minimized to the taskbar, the height is a negative value as i recall   Tongue

Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!