Re: Resize application window - more information
- From: "Karl E. Peterson" <karl@xxxxxxxx>
- Date: Tue, 25 Mar 2008 11:12:16 -0700
Ltexeira wrote:
Your link takes me to download Shell32.zip, which contains the following code
in the hWndShell function. ( Taken directly from the downloaded file )
I am so sorry about that! That truly is ancient. I thought I'd updated that eons
ago.
Perhaps you are referring to a newer version of yours that is not posted for<snip>
download.
If you have a newer version that enumerates, please direct me to it.
Here ya go!
Private Type EnumWindowsData
ProcessID As Long
hWnd As Long
End Type
Public Function hWndShell(ByVal Job As String, Optional WindowStyle As
VbAppWinStyle = vbMinimizedNoFocus) As Long
Dim ProcessID As Long
' *************************************************************************
' Shells a new process and returns the hWnd of its main window.
' *************************************************************************
' Test WindowStyle for reasonableness
If (WindowStyle < vbHide) Or (WindowStyle > vbMinimizedNoFocus) Then
WindowStyle = vbMinimizedNoFocus
End If
' Launch process in requested mode.
On Error Resume Next
ProcessID = Shell(Job, WindowStyle)
On Error GoTo 0
' Determine main window handle for new process.
If ProcessID Then
hWndShell = hWndProcess(ProcessID)
End If
End Function
Public Function hWndProcess(ByVal ProcessID As Long) As Long
Dim ewd As EnumWindowsData
' *************************************************************************
' Fires off enumeration of all windows in system, seeking to return
' toplevel hWnd from requested process.
' *************************************************************************
ewd.ProcessID = ProcessID
Call EnumWindows(AddressOf EnumWindowsProc, VarPtr(ewd))
hWndProcess = ewd.hWnd
End Function
' ***********************************
' Private Methods
' ***********************************
Private Function EnumWindowsProc(ByVal hWnd As Long, lParam As EnumWindowsData)
As Long
Dim PID As Long
' Make sure this is a top-level window.
If GetParent(hWnd) = 0 Then
' Check what process it belongs to
Call GetWindowThreadProcessId(hWnd, PID)
If PID = lParam.ProcessID Then
lParam.hWnd = hWnd
End If
End If
' Return True to continue enumeration if we haven't
' found what we're looking for.
EnumWindowsProc = (lParam.hWnd = 0)
End Function
I'll try to get the update code out there shortly.
Thanks... Karl
--
..NET: It's About Trust!
http://vfred.mvps.org
.
- Follow-Ups:
- Re: Resize application window - more information
- From: Karl E. Peterson
- Re: Resize application window - more information
- References:
- Re: Resize application window - more information
- From: Karl E. Peterson
- Re: Resize application window - more information
- From: Ltexeira
- Re: Resize application window - more information
- From: Karl E. Peterson
- Re: Resize application window - more information
- From: Ltexeira
- Re: Resize application window - more information
- From: Karl E. Peterson
- Re: Resize application window - more information
- From: Ltexeira
- Re: Resize application window - more information
- Prev by Date: Re: Resize application window - more information
- Next by Date: Re: Add-in Directory
- Previous by thread: Re: Resize application window - more information
- Next by thread: Re: Resize application window - more information
- Index(es):
Relevant Pages
|
|