Jump to content
Sign in to follow this  
Lightning87

Disable Close button

Recommended Posts

Lightning87

Is it possible to disable the close button?

Make it grey or something?

Greetz Lightning

Share this post


Link to post
Share on other sites
Manjish

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

Share this post


Link to post
Share on other sites
Yashied

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

Share this post


Link to post
Share on other sites
Jeff West

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)

Share this post


Link to post
Share on other sites
W2lkm2n

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 !

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.