AW: Fenstergröße anderer Anwendung maximieren
25.03.2009 08:28:42
Tino
Hallo,
ist Dir nur der Fenstertitel bekannt, kannst Du es mal hiermit versuchen.
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowTextLength Lib "user32" _
Alias "GetWindowTextLengthA" (ByVal hWnd As Long) _
As Long
Private Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" _
(ByVal hWnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As _
Long) As Long
Private Declare Function ShowWindow Lib "user32" ( _
ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function GetWindow Lib "user32" _
(ByVal hWnd As Long, ByVal wCmd As Long) As Long
Const GWL_STYLE& = (-16)
Const WS_VISIBLE = &H10000000
Const WS_BORDER = &H800000
Const GW_HWNDNEXT& = 2
Const GW_CHILD& = 5
Const iNormal& = 1
Const iMinimized& = 2
Const iMaximized& = 3
Private Function GetWindowInfo(ByVal hWnd&, sTitel$, Optional booVisible As Boolean = True) As Long
Dim Result&, Style&, Title$
'Darstellung des Fensters
Style = GetWindowLong(hWnd, GWL_STYLE)
Style = Style And (WS_VISIBLE Or WS_BORDER)
'Fensetrtitel ermitteln
Result = GetWindowTextLength(hWnd) + 1
Title = Space$(Result)
Result = GetWindowText(hWnd, Title, Result)
Title = Left$(Title, Len(Title) - 1)
'prüfen ob Fenster Sichtbar
If (Style = (WS_VISIBLE Or WS_BORDER)) Or booVisible = False Then
If Title Like "*" & sTitel & "*" Then
GetWindowInfo = hWnd
Exit Function
End If
End If
GetWindowInfo = 0
End Function
'diese Sub minimiert den Internet Explorer
Sub Minimize_Internet_Explorer()
Dim hWnd As Long
Dim Fenstertitel As String
Fenstertitel = "Internet Explorer" 'Hier Fenstertitel anpassen
hWnd = GetDesktopWindow()
hWnd = GetWindow(hWnd, GW_CHILD)
'2. Param. Fenstertitel (nur ein Teil erforderlich)
'3. Param. optional True nur Sichtbare, False alle
GetWindowInfo hWnd, Fenstertitel, True
Do While hWnd <> 0
hWnd = GetWindow(hWnd, GW_HWNDNEXT)
If GetWindowInfo(hWnd, Fenstertitel, True) = hWnd Then
ShowWindow hWnd, iMaximized
End If
Loop
End Sub
Gruß Tino