Hallo erst mal an Alle.
Ich bin ganz neu hier und habe seit einer Woche, nach sehr, sehr langer Zeit, mal wieder ein kleineres Programm mit AutoIt geschrieben.
In meinem Programm wollte ich auch eine MsgBox mit individuellen Buttons haben.
Dazu habe ich eine neue MsgBox Funktion erstellt.
So wie hier von funkey beschrieben:
MsgBox - Beschreibung der Buttons
Die MsgBox funktioniert ja (eigentlich), aber sobald die neue MsgBox beendet wird sind die ersten drei Buttons meiner MainGUI auch umbeschriftet.
Ich habe leider keine Ahnung warum das so ist?
Wie die Routine von funkey funktioniert versteh ich leider nicht so ganz und deshalb habe ich überhaupt keine Ahnung wo da der Fehler liegt.
Zum Testen habe ich mal ein kleines Programm erstellt wo man das wunderbar nachvollziehen kann.
Wäre schön wenn mir mal jemand auf die Sprünge helfen könnte.
Danke schon mal.
Testprogramm:
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
; HauptFenster anlegen
Local $hMainGUI = GUICreate("Test", 200, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseButton")
GUICtrlCreateButton("Button 1", 10, 10, 180)
GUICtrlSetOnEvent(-1, "Button1")
GUICtrlCreateButton("Button 2", 10, 40, 180)
GUICtrlSetOnEvent(-1, "Button2")
GUICtrlCreateButton("Button 3", 10, 70, 180)
GUICtrlSetOnEvent(-1, "Button3")
Local $IDallclose = GUICtrlCreateButton("Close", 10, 130, 180)
GUICtrlSetOnEvent($IDallclose, "CloseButton")
GUISetState(@SW_SHOW, $hMainGUI)
While 1
Sleep(100)
WEnd
Func Button1()
MsgBoxNew($MB_ABORTRETRYIGNORE,"Titel", "Neue drei Tastenbox mit selbst beschriftbaren Tasten")
EndFunc
Func Button2()
MsgBox($MB_OK, "","Button 2 gedrückt")
EndFunc
Func Button3()
MsgBox($MB_OK, "","Button 3 gedrückt")
EndFunc
Func CloseButton()
Exit
EndFunc
; Tasten von MainGUI werden umbeschriftet???
; MsgBox - Beschreibung der Buttons
;
Func MsgBoxNew($flag, $title, $text)
Local $hProcMsgBox = DllCallbackRegister("CbtHookProcMsgBox", "int", "int;int;int")
Local $TIDMsgBox = _WinAPI_GetCurrentThreadId()
Global $hHookMsgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProcMsgBox), 0, $TIDMsgBox)
Local $iRet = MsgBox($MB_ABORTRETRYIGNORE, $title, $text, 0)
_WinAPI_UnhookWindowsHookEx($hHookMsgBox)
DllCallbackFree($hProcMsgBox)
Return $iRet
EndFunc
Func CbtHookProcMsgBox($nCode, $wParam, $lParam)
Local $RET = 0, $hBitmap = 0, $xWnd = 0
If $nCode < 0 Then
$RET = _WinAPI_CallNextHookEx($hHookMsgBox, $nCode, $wParam, $lParam)
Return $RET
EndIf
Switch $nCode
Case 5 ;5=HCBT_ACTIVATE
_WinAPI_SetDlgItemText($wParam, 3, "Ja")
_WinAPI_SetDlgItemText($wParam, 4, "Nein")
_WinAPI_SetDlgItemText($wParam, 5, "Vielleicht")
EndSwitch
Return
EndFunc ;==>CbtHookProcMsgBox
Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString)
Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", "hwnd", $hDlg, "int", $nIDDlgItem, "str", $lpString)
Return $aRet[0]
EndFunc ;==>_WinAPI_SetDlgItemText