Re: Resize application window - more information



Ltexeira wrote:
So the question now becomes : how can I identify the one out of several
handles
associated with the instance is the window itself so I can resize it?

This routine will find the "top-level" window associated with any given hWnd:

Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As
Long

Public Function GetTopLevel(ByVal hChild As Long) As Long
Dim hWnd As Long

' Read parent chain up to highest visible.
hWnd = hChild
Do While IsWindowVisible(GetParent(hWnd))
hWnd = GetParent(hChild)
hChild = hWnd
Loop
GetTopLevel = hWnd
End Function

--
..NET: It's About Trust!
http://vfred.mvps.org


.



Relevant Pages

  • Re: Running Access from network
    ... (ByVal hWnd As Long, _ ... Private Declare Function apiGetDesktopWindow Lib "user32" _ ... Public Function winGetHWndDB(Optional hWndApp As Long) As Long ...
    (microsoft.public.access.forms)
  • Re: Centering the text in a message box
    ... Private Declare Function GetCurrentThreadId& Lib "kernel32" ... "GetClassNameA" (ByVal hwnd&, ByVal lpClassName$, ByVal nMaxCount&) ... Private Declare Function UnhookWindowsHookEx& Lib "user32" ...
    (microsoft.public.excel.programming)
  • Check for Multiple Instance not working in Access 2003
    ... Private Declare Function apiGetDesktopWindow Lib "user32" Alias ... (ByVal hwnd As Long, ByVal lpString As String, ByVal aint As Long) ... Public Function winGetHWndDB(Optional hWndApp As Long) As Long ...
    (comp.databases.ms-access)
  • Check for Multiple Instance not working in Access 2003
    ... Private Declare Function apiGetDesktopWindow Lib "user32" Alias ... (ByVal hwnd As Long, ByVal lpString As String, ByVal aint As Long) ... Public Function winGetHWndDB(Optional hWndApp As Long) As Long ...
    (comp.databases.ms-access)
  • Re: Userform animation
    ... Private Declare Function CreateWindowEX Lib "user32" Alias _ ... Lib "user32" (ByVal hwnd As Long) As Long ...
    (microsoft.public.excel.programming)