KaFu Posted May 9, 2011 Share Posted May 9, 2011 HiHo Forum, took me some time to figure this out. Here's a little tweaked standard help-file example showing what I mean. If you use GUISetState() the call to GUICtrlSetOnEvent() works fine. If you use _WinAPI_SetWindowPos() to show the window, the control events are not called anymore, though the GUI events still work. Start and press OK, close GUI and press OK on the second GUI and you'll see what I mean. Is this a know bug or meant to be this way? expandcollapse popup#include <GUIConstantsEx.au3> #include <Constants.au3> #include <Winapi.au3> Opt('MustDeclareVars', 1) Global $bExit = False Example(1) Example(2) Func Example($iExample) Local $parent1, $ok1, $cancel1 Opt("GUICoordMode", 2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $parent1 = GUICreate("Example #" & $iExample) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") $ok1 = GUICtrlCreateButton("OK", 10, 30, 50) GUICtrlSetOnEvent(-1, "OKPressed") $cancel1 = GUICtrlCreateButton("Cancel", 0, -1) GUICtrlSetOnEvent(-1, "CancelPressed") Switch $iExample Case 1 GUISetState(@SW_SHOW) Case Else _WinAPI_SetWindowPos($parent1, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_SHOWWINDOW)) EndSwitch ; Just idle around While $bExit = False Sleep(10) WEnd GUIDelete($parent1) $bExit = False EndFunc ;==>Example Func OKPressed() MsgBox(0, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) EndFunc ;==>OKPressed Func CancelPressed() MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) EndFunc ;==>CancelPressed Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE MsgBox(0, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) $bExit = True Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Case @GUI_CtrlId = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) EndSelect EndFunc ;==>SpecialEvents Regards OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
trancexx Posted May 9, 2011 Share Posted May 9, 2011 I don't think it's either. AutoIt GUI is shown/whatever with GUISetState(). Anything else may and may not work depending on internal mechanism. In fact it may work today and not tomorrow and then work again the next day. Making conclusions based on that behavior is certainly wrong. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
KaFu Posted May 9, 2011 Author Share Posted May 9, 2011 In fact it may work today and not tomorrow and then work again the next day. Making conclusions based on that behavior is certainly wrong.Makes sense... somehow ... I guess GUICtrlSetOnEvent() somehow processes wm_command messages, and GuiSetState() might register / de-register the processing... or something completely different . Anyway, this way a least the issue can be found by searching. Thanks for taking a look . OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now