Detect Window Maximize event

BlitzMax Forums/BlitzMax Programming/Detect Window Maximize event

GfK(Posted 2008) [#1]
I want to use the maximize button as a shortcut to set my game to fullscreen mode.

I've enabled the button on the window - but I can't figure out how to detect when the user has clicked on it. Currently when I click on it, the window maximizes with my game still running in the top corner in an 800x600 rectangle.

(Don't want to use MaxGUI, either).


Brucey(Posted 2008) [#2]
You can use MaxGUI (source) to find out how it detects it.


GfK(Posted 2008) [#3]
I don't have MaxGUI on this PC and TortoiseSVN says it can't connect to the repository to download it. Sod's law....


GfK(Posted 2008) [#4]
Just had a look at the MaxGUI source on my other PC - might as well be written in chinese.

Any advice?


GfK(Posted 2008) [#5]
I thought I could work around this by waiting for a EVENT_WINDOWSIZE event. It never gets returned.

EVENT_MOUSEMOVE works.

EVENT_WINDOWCLOSE also doesn't work. Clicking the close button seems to return a value of 259, which is not EVENT_WINDOWCLOSE.

I think there's something proplerly wrong here...


tonyg(Posted 2008) [#6]
It couldn't be answered here although it gives a way to get the current status rather than have an event triggered when the button is pushed.


GfK(Posted 2008) [#7]
Sorted it using isZoomed. Like you said, it checks the status rather than detecting the event itself.

Extern "win32"
        Function IsZoomed%(hWnd%) = "IsZoomed@4"
        Function GetActiveWindow%()
End Extern


Then...

	Function update:Object( id,Data:Object,context:Object )
		PollEvent()
		Select CurrentEvent.id
		Case EVENT_MOUSELEAVE,EVENT_APPSUSPEND
			gamestats.display.mouseInWindow = False
		Case EVENT_MOUSEENTER,EVENT_APPRESUME
			gameStats.display.mouseInWindow = True
		End Select
		
		'check for maximised window
		If isZoomed(getActiveWindow())
			If gameStats.display.depth = 0
				gameStats.display.depth = 32
				gameStats.display.fullScreen = True
				gui.changeGraphicsMode()
				scaling = New tScaling
			EndIf
		EndIf
	End Function


Obviously this won't run 'as is' cos its out of my game (this function is added as a flip hook), but you get the idea.


Interested if anybody has a better way...


Retimer(Posted 2008) [#8]
Any advice?


WxWidgets, it's the real stuff compared to the street crack of maxgui.


GfK(Posted 2008) [#9]
WxWidgets, it's the real stuff compared to the street crack of maxgui.
That's not an option.

I don't want to include a massive module just for this. I'm not using MaxGUI either, by the way.


Retimer(Posted 2008) [#10]
Ah sorry, my bad.


Brucey(Posted 2008) [#11]
That's not an option.

a tad overkill, wxWidgets, I'd agree :-p