AW: Wenn ichs könnte
16.12.2003 21:20:54
Nepumuk
Hallo andy,
ja wenn das so ist, also gut, hier der Code. Du solltest mit deinem Level "VBA gut" den Rest selbst gebacken bekommen.
Option Explicit
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd 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 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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Const GWL_STYLE = (-16)
Const WS_VISIBLE = &H10000000
Const WS_BORDER = &H800000
Public Sub GetWindowList()
Dim hWnd As Long, sTitle As String, lStyle As Long
hWnd = GetWindow(FindWindow(vbNullString, vbNullString), GW_HWNDFIRST)
Do
lStyle = GetWindowLong(hWnd, GWL_STYLE) And (WS_VISIBLE Or WS_BORDER)
sTitle = GetWindowTitle(hWnd)
If (lStyle = (WS_VISIBLE Or WS_BORDER)) = True And Trim(sTitle) <> "" Then MsgBox sTitle
hWnd = GetWindow(hWnd, GW_HWNDNEXT)
Loop Until hWnd = 0
End Sub
Private Function GetWindowTitle(ByVal hWnd As Long) As String
Dim lResult As Long, sTemp As String
lResult = GetWindowTextLength(hWnd) + 1
sTemp = Space(lResult)
lResult = GetWindowText(hWnd, sTemp, lResult)
GetWindowTitle = Left(sTemp, Len(sTemp) - 1)
End Function
Code eingefügt mit: Excel Code Jeanie
Gruß
Nepumuk