Jump to content

Disable Close button


Recommended Posts

Assuming that u r refering to an Autoit GUI, yes u can disable any button..

Check GuiCtrlSetState() in helpfile.. set this to $GUI_Disable

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Link to comment
Share on other sites

OP mean the button in the upper right corner of the window.

#Include <GUIMenu.au3>

$hForm = GUICreate('MyGUI')
$hMenu = _GUICtrlMenu_GetSystemMenu($hForm)
_GUICtrlMenu_EnableMenuItem($hMenu, $SC_CLOSE, $MF_GRAYED, False)
GUISetState()

Do
Until GUIGetMsg() = -3
Edited by Yashied
Link to comment
Share on other sites

Try this.

--Jeff

Dim Const $SC_CLOSE = 0xF060

Run("Notepad")
WinWait("Untitled - Notepad")

$handle = WinGetHandle("Untitled - Notepad")
$dSysMenu = DllCall("User32.dll", "hwnd", "GetSystemMenu", "hwnd", $handle, "int", 0)
$hSysMenu = $dSysMenu[0]
DllCall("User32.dll", "int", "RemoveMenu", "hwnd", $hSysMenu, "int", $SC_CLOSE, "int", 0)
DllCall("User32.dll", "int", "DrawMenuBar", "hwnd", $handle)
Link to comment
Share on other sites

  • 3 years later...

Try this.

--Jeff

Dim Const $SC_CLOSE = 0xF060

Run("Notepad")
WinWait("Untitled - Notepad")

$handle = WinGetHandle("Untitled - Notepad")
$dSysMenu = DllCall("User32.dll", "hwnd", "GetSystemMenu", "hwnd", $handle, "int", 0)
$hSysMenu = $dSysMenu[0]
DllCall("User32.dll", "int", "RemoveMenu", "hwnd", $hSysMenu, "int", $SC_CLOSE, "int", 0)
DllCall("User32.dll", "int", "DrawMenuBar", "hwnd", $handle)

Beautiful solution, thank you !
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...