qwert Posted March 13, 2012 Posted March 13, 2012 I use GUICreate with the $WS_POPUP option to build a frameless draggable image ... and it works well. The problem is, there's no clear way for the user to close the window. I don't want to use the ESC/GetMessage method that is often used for testing. Is there a way to enable the Close option of the window's taskbar entry? Apparently for popups, those options are defaulted to NONE, which I can understand for Maximize and Minimize ... but what about Close? Thanks for any help with this.
KaFu Posted March 13, 2012 Posted March 13, 2012 Strange enough the right click taskbar menu exists on Win7 but not on XP using $WS_POPUP . Using this style combo the behavior is the same for both OS. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("My GUI", Default, Default, Default, Default, BitOR($WS_SYSMENU, $WS_POPUP)) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
qwert Posted March 13, 2012 Author Posted March 13, 2012 (edited) KaFu, that's definitely on the right track. Adding $WS_SYSMENU activated the taskbar menu. But I running with On Event Mode, and adding GUISetOnEvent($GUI_EVENT_CLOSE, "ExitFunction") doesn't cause the xClose to be acted upon. If I place a Close Button on the image (GUI) and add a GUICtrlSetOnEvent, that Close Button works ... but xClose still doesn't. Any ideas? Edit: One more thing: I added a second button to bring up a MsgBox from the image GUI ... and the xClose can close the MsgBox, so there's definitely an active association from the taskbar entry to the GUI. Edited March 13, 2012 by qwert
KaFu Posted March 13, 2012 Posted March 13, 2012 (edited) This works fine for me. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) GUICreate("My GUI", Default, Default, Default, Default, BitOR($WS_SYSMENU, $WS_POPUP)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState() While 1 Sleep(10) WEnd Func _Exit() ConsoleWrite("Exit" & @crlf) Exit EndFunc Edited March 13, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
qwert Posted March 13, 2012 Author Posted March 13, 2012 KaFu, thanks for looking into this. Indeed, I think your suggestion is the right one for all normal GUIs. But the particular one I'm working on is compounded by $WS_EX_LAYERED AND $WS_EX_MDICHILD, so there are really two GUIs. I'll bet the xClose is "connected" to the wrong GUI ... the child instead of the parent, for example. I'll just have to start disecting until I can get some simple case that reveals the answer. But you've put me on the right track. Thanks, again for you help.
qwert Posted March 13, 2012 Author Posted March 13, 2012 Solved! ... by one of the first things I tried. I moved the GUISetOnEvent($GUI_EVENT_CLOSE, "ExitFunction") statement to be immediately after the GUICreate Parent. It was down after the Create Child statement, just before the While 1 loop.I didn't know that OnEvent's were associated this way. Indeed, it may only be in certain circumstances ... but this seems to be one of themAnyway, it works.
KaFu Posted March 13, 2012 Posted March 13, 2012 Take a look at the help-file documentation for GUISetOnEvent() and the optional parameter "winhandle". OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
qwert Posted March 13, 2012 Author Posted March 13, 2012 Good to know ... and I had never noticed after using it 100 times. Thanks.
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