AW: shell Fenstergröße bestimmen
08.06.2010 21:44:42
Nepumuk
Servus Sepp,
ein dünner Ast der Titel. Würde ich so machen:
Option Explicit
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByRef lpdwProcessId As Long) As Long
Private Declare Function GetWindow Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal wCmd As Long) As Long
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function GetParent Lib "user32.dll" ( _
ByVal hwnd As Long) As Long
Private Declare Function MoveWindow Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32.dll" ( _
ByVal nIndex As Long) As Long
Private Const GW_HWNDFIRST = 0&
Private Const GW_HWNDNEXT = 2&
Private Const SM_CXSCREEN = 0&
Private Const GWL_STYLE = -&H10
Private Const WS_VISIBLE = &H10000000
Private Const WS_BORDER = &H800000
Public Sub Test()
Dim lngHwnd As Long
lngHwnd = Get_Hwnd("C:\Windows\notepad.exe", vbNormalFocus)
If lngHwnd <> 0 Then _
Call MoveWindow(lngHwnd, GetSystemMetrics( _
SM_CXSCREEN) - 800, 0, 800, 800, 1)
End Sub
Private Function Get_Hwnd(strPfad As String, enmMode As VbAppWinStyle) As Long
Dim lngHwnd As Long, lngTaskId As Long
Dim lngReturn As Long
lngTaskId = Shell(strPfad, enmMode)
lngHwnd = GetWindow(FindWindow(vbNullString, vbNullString), GW_HWNDFIRST)
Do While lngHwnd <> 0
If GetWindowLong(lngHwnd, GWL_STYLE) And (WS_VISIBLE Or WS_BORDER) Then
If GetParent(lngHwnd) = 0 Then
Call GetWindowThreadProcessId(lngHwnd, lngReturn)
If lngReturn = lngTaskId Then
Get_Hwnd = lngHwnd
Exit Do
End If
End If
End If
lngHwnd = GetWindow(lngHwnd, GW_HWNDNEXT)
Loop
End Function
Gruß
Nepumuk