Jump to content

Recommended Posts

Posted

Hi Everyone,

I need to disable minimize, maximize and close buttons on a open window. I've found couple of posts discussing how to do it, but I'm not having much luck making it work.

I've tried following with no luck at all:

WinWait("Notepad")

$calcHwnd = WinGetHandle("Notepad")

Global Const $SC_CLOSE = 0xF060

Global Const $SC_MINIMIZE = 0xF020

Global Const $MF_GRAYED = 0x00000001

$hMenu = DllCall('user32.dll', 'int', 'GetSystemMenu', 'hwnd', $calcHwnd, 'int', 0)

; This should gray out x button?!

DllCall('user32.dll', 'int', 'EnableMenuItem', 'hwnd', $hMenu[0], 'int', $SC_CLOSE, 'int', $MF_GRAYED)

; This should gray out Minimize button?!

DllCall('user32.dll', 'int', 'EnableMenuItem', 'hwnd', $hMenu[0], 'int', $SC_MINIMIZE, 'int', $MF_GRAYED)

WHat am I doing wrong here?? I am using wrong function??

I managed to get following code working, unfortunately it only removes context menu items. Buttons, except for X button, are still functional and visible.

WinWait("Notepad")

$calcHwnd = WinGetHandle("Notepad")

Global Const $SC_CLOSE = 0xF060

Global Const $SC_MINIMIZE = 0xF020

Global Const $SC_MAXIMIZE = 0xF030

Global Const $SC_RESTORE = 0xF120

$menu = DllCall("user32.dll","hwnd","GetSystemMenu","hwnd", $calcHwnd, "int",0)

DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", $SC_MINIMIZE, "int", 0x0)

DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", $SC_MAXIMIZE, "int", 0x0)

DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", $SC_CLOSE, "int", 0x0)

DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", $SC_RESTORE, "int", 0x0)

Any ideas?? I am desperate.

Thanks

Tomas

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
  • Recently Browsing   0 members

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