Functions von Windows erklärung
14.10.2008 14:20:00
Windows
leider weiß ich nicht wo ich nachschauen muss und bitte euch um Hilfe.
Ich Arbeite öfters mit functions wie unten.
Aber frage mich immer wieder wie und was sie zum teill machen oder wozu Sie mnche angaben benötigen.
ich erkläre was ich meine an einem Beispiel.
Ich habe unten die Funktion "GetWindow"
Ganz unten in meinem Code steht:
"hWnd = GetWindow(hWnd, GW_HWNDNEXT) ' nächstes Fenster"
Ich denke das hier mein programm das nächste fenster sucht das offen ist so wie eine for each Schleife.
Habe den code zum glück komplett gefunden aber woher weiß ich sonst was ich angeben muss in der gewünschten konstanten z.b in Const GW_HWNDNEXT = 2 Also woher weiß ich das 2 für das nächste fenster steht.
Ich hoffe ihr habt mich verstanden und könnt mir Tipps geben.
Vielen Dank gruß Chris
Private Declare
Function GetDesktopWindow Lib "user32" () As Long
Private Declare
Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare
Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName _
As String, ByVal nMaxCount 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 PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, LParam As Any) As Long
Private Declare
Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As _
Long
Private Declare
Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As _
Long) As Long
Const GW_CHILD = 5
Const GW_HWNDNEXT = 2
Const GWL_STYLE = (-16)
Const WS_VISIBLE = &H10000000
Const WS_BORDER = &H800000
Sub zeige_alle()
Worksheets(2).Range("A:B").ClearContents
Dim offen As Boolean
Dim hWnd As Long, A As Long
Dim Style
Dim Titel$, Result$
A = Cells(Rows.Count, 1).End(xlUp).Row
hWnd = GetDesktopWindow()
hWnd = GetWindow(hWnd, GW_CHILD)
Do While hWnd 0
Style = GetWindowLong(hWnd, GWL_STYLE)
Style = Style And (WS_VISIBLE Or WS_BORDER)
Result = GetWindowTextLength(hWnd) + 1
Titel = Space$(Result)
Result = GetWindowText(hWnd, Titel, Result)
Titel = Left$(Titel, Len(Titel) - 1)
If Style = WS_BORDER = False Then ' Alle fenster werden angezeigt nicht nur sichtbare
'If (Style = (WS_VISIBLE Or WS_BORDER) = True) Then ' Es werden nur sichtbare Fenster _
angezeigt
If Titel > "" Then
'Titel des Fensters = gewünschtem Titel
'If Titel = fenstername Then
'MsgBox ("Fenster ist gerade offen gefunden ")
' Exit Sub
'End If
A = A + 1
Worksheets(2).Cells(A, 1) = Titel
Worksheets(2).Cells(A, 2) = hWnd
End If
End If
hWnd = GetWindow(hWnd, GW_HWNDNEXT) ' nächstes Fenster
Loop
End Sub