Any way to hide/disable the 'close' gadget?
BlitzMax Forums/BlitzMax Programming/Any way to hide/disable the 'close' gadget?
| ||
Hello. When my game is running in a window, I don't want players to be able to click the "X" to close the window. The user clicking it and nothing happening feels a little odd, yet I don't *want* anything to happen! The player needs to close the game through the game's GUI. Any way to disable it? Or hide it completely? |
| ||
I'm interested in this as well. I guess messing with MaxGUI's CreateWindow and creating a window without a close-button is easier than to remove it from an existing window. |
| ||
Here's the code I use in BlitzPlus, should get you started :)Function RemoveClose(Window) Local hwnd=QueryObject(Window,1) SetWindowLong hwnd,GWL_STYLE,GetWindowLong(hwnd,GWL_STYLE)-WS_SYSMENU RedrawGadget Window End Function |
| ||
Seems a little backwards, why not allow them to close it on the X instead of force them to go through a menu system. You can still clean up and even save once the event is detected. |
| ||
Because I want to avoid closing the game via an accidental click. My game is completely mouse controlled, so accidentally jabbing the close button is always a possibility. Anyhoo, I've made it so that the user needs to click the close button, then click again to confirm. Far less chance of accidentally clicking it twice, I think! |
| ||
yeah that's a good idea, best of both worlds. |
| ||
Well, Im glad you dropped the idea of getting rid of the X, too be honest even on bourderless window game/apps I put a fake graphic one there, because its standard now. People like my mum (for example), wouldnt know how to close the thing otherwise. (And no esc isnt enough) |
| ||
GfK: how are you capturing a user click on the 'X' to determine that the player is trying to exit? You don't have to give away proprietary code or anything, but perhaps you could point to source code or examples you used? Snarty's code means little to me. I've never used BlitzPlus and I know even less about Windows' system stuff. I am not sure where to start to get it to work with my game. Thanks in advance for help! |
| ||
If AppTerminated() I think? |
| ||
You can do what GFK describes with something like...Graphics 400, 300, 0 Repeat cls DrawText MilliSecs(), 170, 144 Flip Until AppTerminate() And Confirm("Really Quit?") End |
| ||
Or through MaxGUI events Russell |
| ||
There's no point importing the entire MaxGUI mod just to do this. |
| ||
There's no point importing the entire MaxGUI mod just to do this Isnt this one of the reasons that the event queue (brl.eventqueue) is now seperate from MaxGui? |
| ||
The event system has *always* been separate from MaxGUI. I think the confusion comes from the fact that the event system was added to BMax at the same time MaxGUI was released. Framework BRL.Basic Import BRL.D3D7Max2D Import BRL.EventQueue Graphics 400, 300, 0 Repeat cls DrawText MilliSecs(), 170, 144 Flip Until (PollEvent() = EVENT_APPTERMINATE) And Confirm("Really Quit?") EndUnless you're gonna be using other events, it's easier (and probably a little quicker?) to just use AppTerminate(). AFAICT, MaxGUI no longer imports 'brl.eventqueque' so Fabian's apps are ~5KB smaller. ;o) |