baldak Posted October 24, 2007 Share Posted October 24, 2007 How can I disable the close button ('X') in a window? Link to comment Share on other sites More sharing options...
monoceres Posted October 24, 2007 Share Posted October 24, 2007 How can I disable the close button ('X') in a window?I'm not sure you can but you don't have to handle the event that is passed down when the user presses the button, or you could define another style to the window like this: GUICreate("Title",300,300,-1,-1,$WS_POPUPWINDOW) Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
smashly Posted October 24, 2007 Share Posted October 24, 2007 If your referring to an AutoIt Gui window then there's a couple of ways.. You could use OnEvent mode 1 , then just not add an exit function on Gui Event close. Or Use Gui register message to catch the X button being clicked. Example catching the X button being clicked using GuiRegisterMsg() and not sending the msg onto the Gui..#include <GUIConstants.au3> Global Const $WM_NCLBUTTONDOWN = 0xA1 GuiCreate("Catch the X Click", 300, 100) GUISetState() GUIRegisterMsg ($WM_NCLBUTTONDOWN, "WM_NCLBUTTONDOWN_FUNC") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func WM_NCLBUTTONDOWN_FUNC($hWnd, $Msg, $WParam, $LParam) $nID = BitAnd($wParam, 0x0000FFFF) If $nID = 20 Then Return 0 Else Return $GUI_RUNDEFMSG EndIf EndFunc If you mean any type of Non-AutoIt window then it's another story... Cheers Link to comment Share on other sites More sharing options...
Zedna Posted October 24, 2007 Share Posted October 24, 2007 (edited) Be careful! There is no standard way to close application therefore HotKeySet with F1 to close #include <GUIConstants.au3> Const $SC_CLOSE = 0xF060 Const $MF_BYCOMMAND = 0x0 Const $MF_GRAYED = 0x1 Const $WM_SYSCOMMAND = 0x0112 HotKeySet("{F1}", "OnF1") $gui = GuiCreate("Catch the X Click", 300, 100) GUISetState() GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND") $hMenu = DllCall("user32.dll", "hwnd", "GetSystemMenu", "hwnd", $gui, "int", 0) ;~ DllCall("user32.dll","hwnd","DeleteMenu", "hwnd", $hMenu[0], "int",$SC_CLOSE, "int", $MF_BYCOMMAND) DllCall("user32.dll","hwnd","EnableMenuItem", "hwnd", $hMenu[0], "int",$SC_CLOSE, "int", BitOr($MF_BYCOMMAND,$MF_GRAYED)) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd ; to disable Alt+F4 Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0xFFF0) = $SC_CLOSE Then Return EndFunc Func OnF1() Exit EndFunc Edited October 24, 2007 by Zedna mesale0077 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Elzie Posted March 28, 2015 Share Posted March 28, 2015 How about ##include <GUIConstants.au3> #include <WindowsConstants.au3> Const $SC_CLOSE = 0xF060 HotKeySet("{F1}", "OnF1") $gui = GUICreate("Click The X ", 269, 48, 2734, 529, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE)) $Label1 = GUICtrlCreateLabel("Press F1 to close", 0, 0, 266, 41) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) GUISetState(@SW_SHOW) While 1 WEnd Func OnF1() Exit EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted March 28, 2015 Developers Share Posted March 28, 2015 Not sure our friend Baldak will see this as he hasn't been onlibe sinds oct 2007. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 28, 2015 Moderators Share Posted March 28, 2015 Elzie,You are beginning >to make a habit of necroing very old threads - please stop it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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