|
Hilfe zum Thema: Visual-Basic, Setwindowtext, Vb6, Api
Re: so gehts
Du kannst einen API-Timer starten und dann im Timer-Event die Msgbox suchen und den WindowText der Buttons ändern. Ein VB-Timer funktioniert hier nicht weil das VB-Timerevent von der MsgBox blockiert wird, die API-Timerfunktion hingegen wird aufgerufen. Aufruf der Msgbox
Private Sub Command1_Click() StartTimer 1 MsgBox "Ja Nein Abbrechen", vbYesNoCancel, "MsgBox" End Sub
Wegen dem Callback beim Timer muß das in ein Modul
Option Explicit Private Const GW_CHILD = 5 Private Const GW_HWNDNEXT = 2 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Private MtmrID As Long Public Sub StartTimer(ByVal intMilliSeconds As Integer) MtmrID = SetTimer(0, 0, intMilliSeconds, AddressOf CallBackTimerProc) End Sub Public Sub StopTimer() If MtmrID <> 0 Then KillTimer 0, MtmrID End If End Sub Public Sub CallBackTimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long) Dim hwndDialog As Long Dim hwndButton As Long StopTimer hwndDialog = FindWindow("#32770", "MsgBox") '// <-- Titel der Msgbox angeben If hwndDialog > 0 Then hwndButton = GetWindow(hwndDialog, GW_CHILD) Do While hwndButton > 0 If ClassName(hwndButton) = "Button" Then Select Case WindowText(hwndButton) Case "&Ja" SetWindowText hwndButton, "super" Case "&Nein" SetWindowText hwndButton, "nee du" Case "Abbrechen" SetWindowText hwndButton, "vielleicht" End Select End If hwndButton = GetWindow(hwndButton, GW_HWNDNEXT) Loop End If End Sub Private Function ClassName(ByVal hwndWindow) As String Dim lngLen As Long Dim strText As String strText = Space(256) lngLen = GetClassName(hwndWindow, strText, Len(strText)) ClassName = Left$(strText, lngLen) End Function Private Function WindowText(ByVal hwndWindow As Long) As String Dim strText As String Dim lngLen As Long strText = Space(GetWindowTextLength(hwndWindow) + 1) lngLen = GetWindowText(hwndWindow, strText, Len(strText)) WindowText = Left$(strText, lngLen) End Function
|
Google-Anzeigen
| Weitere Informationen zu diesen Themen: |
|
Api |
|
|
|