Welcome! Log In Create A New Profile

Advanced

WINDEV Minimize and System Menu(Close)

Posted by jonlau 
WINDEV Minimize and System Menu(Close)
October 10, 2018 06:29AM
Hi,

Is there anyway to show the Window Minimize without showing the closed "X" on the window system menu?

Or is there code to prevent user to click on the "X" ?

Regards,

Jon Lau
Re: WINDEV Minimize and System Menu(Close)
October 10, 2018 08:11AM
Hi,

you HAVE TO have some way to close an application, preferably by clicking a menue-item oder a button. You have to choose between intentionally closing the project and closing it using the X in the upper right corner of the window. So, when the button CloseTheDamnedProject is clicked then it runs

WeReallyShutDown = True
Close()

Your project has an event "Closing YourProject"

Here, you have some code

IF WeReallyShutDown = False THEN ReturnToCapture(CloseTheDamnedProject)

Close()

BR G. Predl
Re: WINDEV Minimize and System Menu(Close)
October 10, 2018 01:45PM
Hi

first, NO... if you ant the SYSTEM minimize button, you will also get the close button

Second, you have several solutions to do what you want:

1. remove the whole title bar and replace it by a static with your title and YOUR minimize button with the minimize function in it

OR

2. Keep the system title bar with all button but add a hidden button with ALT+F4 as a shortcut... Instead of closing the window the X click will call this button (and the alt F4 will not close your app either)... put whatever code you want in it

Best regards

Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Free Video Courses, free WXShowroom.com, open source WXReplication, open
source WXEDM.

More information on [www.fabriceharari.com]
Re: WINDEV Minimize and System Menu(Close)
October 10, 2018 01:56PM
Hello Jon,

You can do this by removing the system icons and use your own buttons for min/max and close. then in the code of the button use.

I have a app that is MDI and on all child windows I use a blank window not even boarders then I use my own system looking buttons.

//code to hide the window and put in system tray
SysIconAdd(fExeDir()+"\Your_Icon.ico",MENU_RightClickMenu,"CT Barcode Import","RestoreWindow")
WinStatus(Invisible)

create a popup menu "MENU_RightClickMenu" with 1 option "Restore"

for the code of the "Restore" option call "RestoreWindow(WM_LBUTTONDBLCLK)"

//Code to show the window when the user right clicks on the icon in system tray
PROCEDURE RestoreWindow(nOperation is int)

// Restores in double click
IF nOperation = WM_LBUTTONDBLCLK THEN
	WinStatus(Active)	
END

DW
Al
Re: WINDEV Minimize and System Menu(Close)
October 10, 2018 03:45PM
Hello Jon

Here are a couple of procedures with realy old code.
It still works in windows 10 in Windev 22
I use them in the window opening code to hide the close "X"
PROCEDURE TurnOffSystemMenuX
////f16.parsimony.net/forum28986/messages/32491.htm
//// -0x1 Disable Maxime
//// -0x2 Disable Minimize
//// -0x8 Disable the system menu (icon, max & min buttons, etc)
//// -040 Disable tittle bar
//// -0x4 Disable resize
//cpFlags is unsigned int = 0x400
//lpHandleMenu is 8byte int = API("user32", "GetSystemMenu",Handle(),0)
//API("user32", "DeleteMenu", lpHandleMenu, 6, cpFlags)
//// one removes also the bar of separation
////AppelDLL32("user32", "DeleteMenu", lpHandleMenu, 5, cpFlags)

//24/01/13
//this is bjoern's code with alterations
LnErrCode is 8byte int = 0

hMenu is system int                             // Type C :HMENU
uPosition is unsigned int = 6                // Type C :UINT
uFlags is unsigned int = 0x400            // Type C :UINT

hWnd is system int     = Handle()           // Type C :HWND
bRevert is boolean  = 0                        // Type C :BOOL

hMenu = API( "USER32", "GetSystemMenu", hWnd, bRevert )    
IF hMenu THEN 
	IF NOT API( "USER32", "DeleteMenu", hMenu, uPosition, uFlags ) THEN 
		LnErrCode = API("KERNEL32","GetLastError")
		//Trace(errCode)
	END
	
 END


//Bjoern's code
//PROCEDURE RemoveCloseButton(LOCAL _hwnd is system int)
//    res is boolean
//    errCode is 8byte int = 0
//
//    hMenu is system int                             // Type C :HMENU
//    uPosition is unsigned int = 6                // Type C :UINT
//    uFlags is unsigned int = 0x400            // Type C :UINT
//
//    hWnd is system int     = _hwnd            // Type C :HWND
//    bRevert is boolean  = 0                        // Type C :BOOL
//
//    hMenu = API( "USER32", "GetSystemMenu", hWnd, bRevert )    
//    IF hMenu THEN 
//        IF NOT API( "USER32", "DeleteMenu", hMenu, uPosition, uFlags ) THEN 
//            errCode = API("KERNEL32","GetLastError")
//            Trace(errCode)
//        END
//
//     END


PROCEDURE TurnOnSystemMenuX
Masque is 8byte int

GWL_STYLE is 8byte int = -16

RDW_FRAME is system int = 1024
RDW_INVALIDATE is system int = 1
RDW_UPDATENOW is system int = 256

WS_MAXIMIZEBOX is system int  = 65536
WS_MINIMIZEBOX is system int = 131072
WS_SYSMENU is system int = 524288

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

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

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

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

Regards
Al
Re: WINDEV Minimize and System Menu(Close)
October 10, 2018 05:17PM
Thank you all for the solution.
I will try/test them.
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: