Maximise Button (again) [MAXGUI]+[NON]

BlitzMax Forums/BlitzMax Beginners Area/Maximise Button (again) [MAXGUI]+[NON]

Grisu(Posted 2006) [#1]
Hello!

Does someone know how one can:

1.
Create a plain window with maxgui (no statusbar, menu!) and check if the maximise button is clicked? The helptext given to "Createwindow" doesn't give that much info... :(

2.
Check the maximise Button event with a normal app in window mode? "Graphics 800,600,0" e.g.


kfprimm(Posted 2006) [#2]
1. just check for a EVENT_WINDOWSIZE event
2. cant help you there :-(


Hotcakes(Posted 2006) [#3]
2. Impossible without rewriting the DX and OGL Max2D modules to make use of MaxGUI directly (or adding the features you need manually) - and these modules are an absolute shambles.


Grisu(Posted 2006) [#4]
Thanks for the answers.

My idea was to create a window with maxgui as a workaround.
But even this seems impossible for me, I just want to create a 800x600 window with min, max, close buttons, NON resizable.
But I don't know the flag to set such a window.

And the helpfile does not list all flags possible here. :(


Bremer(Posted 2006) [#5]
This example should make a 800x600 window with min,max,close buttons that cannot be resized.

Graphics 800,600,0

Extern "win32"
	Function GetActiveWindow()
	Function GetWindowLongA(hWnd%, nIndex%) = "GetWindowLongA@8"
	Function SetWindowLongA(hWnd%, nIndex%, uFlags%) = "SetWindowLongA@12"
	Function DrawMenuBar%(hMenu%)
End Extern

Const WS_MAXIMIZEBOX:Long = $10000
Const WS_MINIMIZEBOX:Long = $20000
Const GWL_STYLE:Int = -16

' example
Local handle:Long = GetActiveWindow()
fixWindow( handle )

Repeat
  Cls 
  SetColor 255,255,255
  DrawText "Window with minimize, maximize and close button.", 20,20
  DrawText "that cannot be resized.", 20,40
  Flip 
Until KeyHit(KEY_ESCAPE) Or AppTerminate()

Function fixWindow( hWnd:Long )
	Local tmp:Int = GetWindowLongA( hWnd, GWL_STYLE )
	tmp = tmp | WS_MAXIMIZEBOX
	tmp = tmp | WS_MINIMIZEBOX
	SetWindowLongA( hWnd, GWL_STYLE, tmp )
	DrawMenuBar( hWnd )
End Function



Grisu(Posted 2006) [#6]
zawran, the idea was to switch over to Maxgui. There one should be able tracking the click of the maximise button.
Though I don't know how.

I have your code to show a maximise button with normal bmx, but as we can't check the event there. Its kind of useless for my purpose.


Bremer(Posted 2006) [#7]
I don't think that you can get an event for clicking on the maximize button even with maxgui. From what I have been able to find so far, you can only get events from the window being resized, but that could also be because its being minimized. I have been trying to find out via the MSDN website, but nothing so far. But I will keep looking as I could use this myself.


Grisu(Posted 2006) [#8]
I'm frustrated that such "simple" suff can't be done with bmx.
Every windows app has these 3 buttons.

Why is this so difficult for bmx? :((((((((((((


EOF(Posted 2006) [#9]
See:

WindowMaximized( window:TGadget )
WindowMinimized( window:TGadget )
SetMinWindowSize( window:TGadget,w,h )


Yan(Posted 2006) [#10]
...Oops, brain spasm...


degac(Posted 2006) [#11]
the only answer I have: this is the first version of MaxGUI, in the next update will have 'more control' on the interface...
I hope so!


Bremer(Posted 2006) [#12]
WindowMaximized( window:TGadget )
WindowMinimized( window:TGadget )


Unless I am mistaken, which I might well be, then those commands only tells you if the window is either maximized or minimized, and they cannot be used to capture the event that someone clicks on the buttons. But one could ofcause make a flag variable which holds the current state, and then check that against the WindowMaximized result and then act on that.

Its just not the same as getting an actual event trigger from the user clicking. I have been trying to dig through the MSDN info, but haven't found any events that does this, so I am not even sure that it can be done internally in windows and therefore probably not be done with MaxGUI either.


Grisu(Posted 2006) [#13]
Perhaps Jim can explain that a bit?

I confess this stuff is too high for me... :(


Josepho(Posted 2008) [#14]
I found this topic using the search engine, anybody knows how can i scale the viewport of the game when i use the maximize button?


kfprimm(Posted 2008) [#15]
Local rect[4]
GetClientRect GetActiveWindow(),rect
Local width=rect[2]-rect[0]
Local height=rect[3]-rect[1]

That'll get you the width/height of the graphics window.


Josepho(Posted 2008) [#16]
Thanks but i think i would need more help, how do i scale all the game images thinking that i use the setscale function and different imagehandles to make some effects? Can i draw it first in an image like a render to texture and then scale this image? Donno what to do -_-


Ked(Posted 2008) [#17]
After the graphics window is finished sizing or while it's sizing use SetViewport 0,0,GraphicsWidth(),GraphicsHeight(). I think this is what you're talking about.


Josepho(Posted 2008) [#18]
No, that doesnt fix my problem, when i click the maximize button the graphicswidth and graphicsHeight still the same, and i dont think that using only the setviewport function will fix my problem, i need a way to scale the whole viewport too!


QuickSilva(Posted 2008) [#19]
Just curious Josepho, did you ever manage to work out what you wanted to do as I`m after something similar.

Jason.


GfK(Posted 2008) [#20]
Projection Matrix.

I'm using the code from Yan's post, about 2/3 of the way down that page.

By the way, its much easier to use than it first appears! You basically set the screen resolution as normal, then use TVirtualGraphics.set() - this will stay the same throughout your game, even if the user changes screen res (Just call TVirtualGraphics.set() again). I write my game logic to run correctly at 800x600, so I just give those parameters to TVirtualGraphics.

Other than that, any occurence of GraphicsWidth()/GraphicsHeight() should be replaced with TVirtualGraphics.VirtualWidth/VirtualHeight, and use TVirtualGraphics.MouseX()/MouseY() instead of the usual MouseX() and MouseY().

That's about it.


QuickSilva(Posted 2008) [#21]
Thanks GfK. Now that you mention it I seem to recall you telling me about this before in another post and I did think it was a little complex at the time.

I`ll be sure to have another look at it though.

Cheers,
Jason.