Dynamically resizing the game window?

BlitzMax Forums/BlitzMax Beginners Area/Dynamically resizing the game window?

Bukky(Posted 2006) [#1]
Hey guys,

How does one go about being able to dynamically resize the game window during gameplay? That is to say, how do I make my game respond to "alt+enter" as well as the minimize/maximize icon in the upper right hand corner of my application window?


Robert Cummings(Posted 2006) [#2]
You could buy grey alien's framework if you want a really quick and easy solution with source code.

If not, then you need to call Graphics again. Don't worry about reloading or end graphics as blitz will take care of all this.

So you just need to check for alt + enter using keydown.

As for the minimise thing,

	?Win32
		Function EnableMinimize(hWnd:Long)
			Local tmp:Long = GetWindowLongA( hWnd, GWL_STYLE )
			tmp = tmp | WS_MINIMIZEBOX
			SetWindowLongA( hWnd, GWL_STYLE, tmp )
			DrawMenuBar( hWnd )
		End Function
	?


That should do it. You need to pass in the hwnd which can be obtained when your app starts ie GetActiveWindow()


Grisu(Posted 2006) [#3]
http://www.blitzbasic.com/codearcs/codearcs.php?code=1595


ImaginaryHuman(Posted 2006) [#4]
You need to call SetGraphics again with a new context in the right size. But you don't have to call Graphics() again, the window should stay open as you switch contexts.


ImaginaryHuman(Posted 2006) [#5]
I wish you guys would come up with cross-platform solutions ;-D


Bukky(Posted 2006) [#6]
Cool! Thanks guys!

One more thing though, using the method outlined in Grisu's link, is there a way to keep the bar with the buttons visible while the game is in fullscreen mode?


Bukky(Posted 2006) [#7]
And here is another thing:

Global depth = 0

Graphics 800,600, depth
Global hWnd% = GetActiveWindow() 
enableMinimize( hwnd% )
enableMaximize( hwnd% )

While exit_flag = "false" And Not AppTerminate()


If iszoomed(hWnd) Then
	EndGraphics()
	Global depth = 32
	Graphics(800, 600, 32)
EndIf

If KeyDown(KEY_LALT) And KeyDown(KEY_ENTER)
	If depth = 0 Then depth = 32 Else depth = 0
		EndGraphics()
		Graphics(800,600,depth)
		If depth = 0 Then 
			enableMinimize( hwnd% )
			enableMaximize( hwnd% )
		End If 
EndIf

        GCCollect()
	Flip
	Cls
Wend




When I minimize my window again, the buttons for for maximize and minimize are gone. Anyone know what the issue may be?