Welcome! Log In Create A New Profile

Advanced

ping Deek, Marc Min-Maximies Button enable/disable source

Posted by BLS 
Hi folks,
I've opened a new thread, 'cause maybe other community members are interested.

So here we go :
Disable Maximize Button
FUNCTION DisableMaximizeButton( nHandle is int )
	nStyle	is int
	
	nStyle = API( "User32", "GetWindowLongA", nHandle,  -16 ) // GWL_STYLE
	nStyle = BinaryAND( nStyle, BinaryNOT(65536) )   //WS_MAXIMIZEBOX
	
	bRes is boolean = ( API( "User32","SetWindowLongA",nHandle, -16,nStyle ) <> 0 ) 

	IF bRes THEN
		RESULT ( API( "User32","SetWindowPos",nHandle, 0,0,0,0,0,0x27 ) <> 0 ) 
	ELSE
		RESULT False			
	END

Enable Maximize Button

FUNCTION EnableMaximizeButton( nHandle is int )
	nStyle	is int
	
	nStyle = API( "User32", "GetWindowLongA", nHandle,  -16 ) // GWL_STYLE
	nStyle = BinaryOR( nStyle, 65536 )
	
	bRes is boolean = ( API( "User32","SetWindowLongA",nHandle, -16,nStyle ) <> 0 )
	
	IF bRes THEN 
		RESULT ( API( "User32", "SetWindowPos", nHandle, 0,0,0,0,0,0x27 ) <> 0 ) 
	ELSE
		RESULT False			
	END

Disable Minimize Button

FUNCTION DisableMinimizeButton( nHandle is int )
	nStyle	is int
	
	nStyle = API( "User32", "GetWindowLongA", nHandle,  -16 ) // GWL_STYLE
	nStyle = BinaryAND( nStyle, BinaryNOT(131072) )   //WS_MINIIMIZEBOX
	
	bRes is boolean = ( API( "User32","SetWindowLongA",nHandle, -16,nStyle ) <> 0 ) 

	IF bRes THEN
		RESULT ( API( "User32","SetWindowPos",nHandle, 0,0,0,0,0,0x27 ) <> 0 ) 
	ELSE
		RESULT False			
	END

Enable Minimize Button surprise, surprise smiling smiley

FUNCTION EnableMinimizeButton( nHandle is int )
	nStyle	is int
	
	nStyle = API( "User32", "GetWindowLongA", nHandle,  -16 ) // GWL_STYLE
	nStyle = BinaryOR( nStyle, 131072 )   //WS_MINIIMIZEBOX
	
	bRes is boolean = ( API( "User32","SetWindowLongA",nHandle, -16,nStyle ) <> 0 ) 

	IF bRes THEN
		RESULT ( API( "User32","SetWindowPos",nHandle, 0,0,0,0,0,0x27 ) <> 0 ) 
	ELSE
		RESULT False			
	END


Place the following code, into your Window init. section

        // Window init.section
        IF DisableMaximizeButton(NAME_OF_CHILDWINDOW) THEN
        END
        IF DisableMinimizeButton(NAME_OF_CHILDWINDOW) THEN
        END


Please Note :
Using both DisableXXX functions within your window init; section will hide the Min-Max Buttons.
Using just one of them will make the XXX button grey (disabled)
Play with it and you'll see ...

To disable/enable the System menu, just change the WS_XXX parameter. Guess WS_SYSMENU

Code is written by Bjoern Lietz-Spendig and is public domain.

To Derek T;
Disable/Hide the close button is afaik not possible. But I am working on a tabbed MDI interface. In order to do that I have to remove the title/caption bar of the MDI child windows.
Maybe this is also a working solution for you. In case that the code is short enough I'll publish it here.

Derek are you one of the Australian WD fellows ? Then you are a lucky guy. Australien Beer forever smiling smiley
Bjoern
Hello Bjoern

I got this code way from the old forum some years ago. It hides the close X on the window system menu

PROCEDURE TurnOnSystemMenuhot smiley)
Masque is int
GWL_STYLE is int = -16
RDW_FRAME is int = 1024
RDW_INVALIDATE is int = 1
RDW_UPDATENOW is int = 256
WS_MAXIMIZEBOX is int = 65536
WS_MINIMIZEBOX is int = 131072
WS_SYSMENU is int = 524288

Masque = CallDLL32("user32","GetWindowLongA",Handle(),GWL_STYLE)

Masque = BinaryOR(Masque,WS_MINIMIZEBOX)
Masque = BinaryOR(Masque,WS_MAXIMIZEBOX)
Masque = BinaryOR(Masque,WS_SYSMENU)

CallDLL32("User32","SetWindowLongA",Handle(),GWL_STYLE,Masque)

CallDLL32("User32", "RedrawWindow", Handle(), Null, Null, RDW_FRAME+RDW_INVALIDATE+RDW_UPDATENOW)


PROCEDURE TurnOffSystemMenuhot smiley)
cpFlags is int = 0x400
lpHandleMenu is int = AppelDLL32("user32", "GetSystemMenu",Handle(),0)
AppelDLL32("user32", "DeleteMenu", lpHandleMenu, 6, cpFlags)
// one removes also the bar of separation
//AppelDLL32("user32", "DeleteMenu", lpHandleMenu, 5, cpFlags)

Regards
Al





Edited 1 time(s). Last edit at 09/27/2008 02:36PM by Al.
Hi Al ! (exandre) ?

Thanks for sharing ! I'll add this code to my API library.
Bjoern
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: