| |
| Publicado el 23,noviembre 2016 - 11:30 |
Hi All
How does one disable the X [close button] in the Title Bar without disabling the Close option in the System menu? I want the user to be able to close the app but not with the X in the Title Bar. The only option I am leaving there is the minimize button.
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 12:00 |
Hi André,
Several options: - Create a window without a title bar - Use windows API's to nuke the X-button on the title bar - Create a new (hidden button) that has the ALT+F4 shortcut. Clicking the X button of the window (or the close option from the system menu) will be redirected to the code in this button allowing you to give more options...
Although, to me it seems to be a very specific busines case as it will break any UI Windows conventions set out... But... I assume you have a valid reason to do it this way.
Best regards,
Peter Holemans |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 12:29 |
Hello Andre
Here are some very old procs to turn the X on and off as well as a few other things
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 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
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) |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 18:04 |
Hi Peter
A very specific reason for this. It is a very rich communication app with lots of functions that will pop up with messages as part of its function. The user can close the messages and then minimize the app - it always starts at runtime - the X button is too close to the minimize button and the natural tendency for users is to press X after flipping through the messages. That means it is not running and any future messages will not be caught. When minimized and a message is detected it comes to the fore and displays the message. This is one of dozens of functions. If the user wants to close the app we would prefer them to explicitly go to the system menu and close it there. The X is likely to contribute to many accidental closings of the app.
Hope that makes sense.
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 18:07 |
Thanks a ton for that code Al. Will try it out.
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 18:19 |
Hi Al
That worked but it actually removes the Close entry on the system menu. I am hoping to just disable the X on the title bar. That would be first prize.
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 18:54 |
Hi Andre, then the best solution is to use the ALT-F4 technique that Peter gave you
Steven Sitas |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 18:59 |
Hi Steven
I have actually now been able to grey out the X button and that simply greys out the Close option in the system menu as well. I agree that Peter's option seems the best - I wonder if it is possible to halt the exit with a message? That would be ideal. I just want to turn the user's attention to what they are doing and the implications. X does not minimize - that is pretty much it. Will try that now.
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 19:07 |
Hi Peter
The Alt-F4 trick does not seem to work. It is not redirected to the button. There must be a spot where one can capture on exit. Looking.......
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 19:09 |
Hi All
Found that - on closing the app - but how can I halt a closing if the user agrees that was not the intention? Is there a way of doing that?
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 19:26 |
Hi Andre,
Here is the way we do it in the new version of alpha360 ERP (v0.5) - available in a couple of days.
1. On the main window - with the [x] button - we add a Popup Menu, say PopupClose. 2. In the PopupClose we have one Option Called Logout. 3. In this Option - in the code area - we have a YES NO question to the user and if a user chooses YES, we do some "cleaning" and then call EndProgram.
4. We add a BUTTON to this main window, outside the VISUAL area, to the right. 5. This BUTTON has a SHORTCUT equal to ALT+F4 6. On the Click code of this Button we just call OpenPopupMenu(PopupClose)
Thats it ...
Steven Sitas |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 19:42 |
Hi Steven
The Alt+F4 on my button is not working. The app just closes. I wonder what could be wrong? Maybe it must be visible. But I have called no visible buttons before.
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 20:07 |
Hi Andre, the Button must be VISIBLE and of course NOT Disabled. Thats why we add it OUTSIDE the boundaries of our WINDOW - to "hide it" without using HIDE.
Steven Sitas |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 20:18 |
Hi Steven
I have it as visible and enabled. Still no go. The app just closes. Must be missing something here.
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2016 - 20:31 |
Hi Steven
Sorted - the button was on the wrong plane. Place it on zero and boom. Works like a charm.
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 24,noviembre 2016 - 04:17 |
I have not tried either of these options but I would consider
(1) WinSystemButton()
(2) In the Close method of the window using ReturnToCapture()
Stewart Crisler |
| |
| |
| | | |
|
| | |