Any way to hide/disable the 'close' gadget?

BlitzMax Forums/BlitzMax Programming/Any way to hide/disable the 'close' gadget?

GfK(Posted 2007) [#1]
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?


Jake L.(Posted 2007) [#2]
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.


Snarty(Posted 2007) [#3]
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



Grey Alien(Posted 2007) [#4]
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.


GfK(Posted 2007) [#5]
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!


Grey Alien(Posted 2007) [#6]
yeah that's a good idea, best of both worlds.


H&K(Posted 2007) [#7]
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)


Tachyon(Posted 2007) [#8]
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!


Damien Sturdy(Posted 2007) [#9]
If AppTerminated() I think?


Yan(Posted 2007) [#10]
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



Russell(Posted 2007) [#11]
Or through MaxGUI events

Russell


GfK(Posted 2007) [#12]
There's no point importing the entire MaxGUI mod just to do this.


H&K(Posted 2007) [#13]
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?


Yan(Posted 2007) [#14]
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?")

End
Unless 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)