Jump to content
Sign in to follow this  
selfexploiter

user32.dll Disable Restore-Button

Recommended Posts

Hi,

I'm trying to adapt the solution below for the Restore/Minimize/Maximize-Buttons (0xF020,0xF030,0xF120) in an external program.

The commands seem to work at removing the items from the menus themselves, but it doesn't disable the actual icons. Interestingly enough, if the Close menu item is removed (like below), the × does get dimmed.

How can I get this (the dimming) working for the other Buttons?

Thank very much for helping in advance.

Lars

Please post questions in the Support forum instead of Scripts and Scraps.

But to answer your question:

; Example of external program

Run("calc")

WinWait("Calculator")

$calcHwnd = WinGetHandle("Calculator")

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

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

...

Share this post


Link to post
Share on other sites

Buttons are not grayed out, but they are disabled:

Run("notepad")
WinWait("Untitled - Notepad")
$calcHwnd = WinGetHandle("Untitled - Notepad")

Global Const $SC_CLOSE = 0xF060
Global Const $SC_MINIMIZE = 0xF020
Global Const $SC_MAXIMIZE = 0xF030;

$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)

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

@CyberSlug

Thank you for your reply!

I was able to get it running on my machine.

But my problem still remains.

By googling the web i found following code snippet related to another scripting language.

;constants
user32=StrCat(DirWindows(1),"user32.dll")
WS_MAXIMIZEBOX=65536
GWL_STYLE=-16
;remove maximize style
oldstyle=DllCall(user32,long:"GetWindowLongA",long:handle,long:GWL_STYLE)
newstyle=oldstyle & ~WS_MAXIMIZEBOX
DllCall(User32,long:"SetWindowLongA",long:handle,long:GWL_STYLE,long:newstyle)

Maybe this is the base for an AutoIt-Solution. But my knowledge is too little to adapt it by my self.

In another thread i have found a similiar solution by Larry for an AutoIt-Gui-Project

#include <GUIConstants.au3>

Global $GWL_STYLE = -16

$hWnd = WinGetHandle("AutoIt Forums")

$OldStyle = DLLCall( "user32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE )
If @error Then Exit
$OldStyle = $OldStyle[0]

$NewStyle = BitAND($OldStyle,BitNOT($WS_CAPTION) )

DLLCall( "user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", $NewStyle )

Sleep(2000)

DLLCall( "user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", $OldStyle )
WinSetState($hWnd,"",@SW_MINIMIZE)
WinSetState($hWnd,"",@SW_RESTORE)

Is this a point to move on to reach the graying out of the controls in the titlebar?

second problem:

I have found out that disabled maximizing and restoring did not inhibit the resizing by doubleclick on the titlebar (e.g. IE 6). Is there a parameter preventing this?

Thank you for your further comments

Greetings

Lars

P.S. Please excuse my bad English. I know, i have to improve it urgently

Share this post


Link to post
Share on other sites

Run("notepad")
WinWait("Untitled - Notepad")
$calcHwnd = WinGetHandle("Untitled - Notepad")

Global Const $SC_CLOSE = 0xF060
Global Const $SC_MINIMIZE = 0xF020
Global Const $SC_MAXIMIZE = 0xF030;

$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)

I can't get @CyberSlug's above code to work. All buttons are functional.

Edited by Arnie

Share this post


Link to post
Share on other sites

Run("notepad")
WinWait("Untitled - Notepad")
$calcHwnd = WinGetHandle("Untitled - Notepad")

Global Const $SC_CLOSE = 0xF060
Global Const $SC_MINIMIZE = 0xF020
Global Const $SC_MAXIMIZE = 0xF030;

$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)

I can't get @CyberSlug's above code to work. All buttons are functional.

The above script works for the "close" button. How would you disable the "restore" button?

Share this post


Link to post
Share on other sites

Run("notepad")
WinWait("Untitled - Notepad")
$calcHwnd = WinGetHandle("Untitled - 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)


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Run("notepad")
WinWait("Untitled - Notepad")
$calcHwnd = WinGetHandle("Untitled - 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)

Same result, only the "close" button gets disabled.

Share this post


Link to post
Share on other sites

It's disabling the Restore "Menu" not the button. Thus "RemoveMenu".

Edit:

Might want to look at SWP_NOMOVE / SWP_NOSIZE: http://msdn.microsoft.com/library/default....etwindowpos.asp

Edit2:

See above link, I gave the wrong one the first time.

Edit3:

I'm staying away from the computer today, that link has absolutely nothing to do with what your looking for!! :D

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

It's disabling the Restore "Menu" not the button. Thus "RemoveMenu".

Edit:

Might want to look at SWP_NOMOVE / SWP_NOSIZE: http://msdn.microsoft.com/library/default....etwindowpos.asp

Edit2:

See above link, I gave the wrong one the first time.

Edit3:

I'm staying away from the computer today, that link has absolutely nothing to do with what your looking for!! :D

Lol...anyone else..How to disable the "restore" button?

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...