Get TGadget of Grapics "800,600,0"?

BlitzMax Forums/BlitzMax Beginners Area/Get TGadget of Grapics "800,600,0"?

Grisu(Posted 2006) [#1]
Hi!

I'm still trying to figure out how to detect the click on the maximise button of a window.

Is there a way to get the current TGadget of the window I'm using? (No CreateWindow involved, simply Graphics 800,600,0) If so one could then use the normal maxgui eventchecks on it.


Eric(Posted 2006) [#2]
I think EVENT_WINDOWSIZE. Can't be 100% certain.


Diablo(Posted 2006) [#3]
i think he means he wants to be able to get the tgadget for the window that is created when you use graphics. I tho you might beable to go event.source but it doesnt work :(. Other then that i know of no other command that could do it.

Just out of intrest i tried doing a waitevent and event check and the window graphics window does throw up events, however i dont think they comfrom to the maxgui standared as i tried making the program close on EVENT_WINDOWCLOSE however it didnt work as its not the same value but i did get it to close in the end, i think it throws up 259 or.. mmm heres the code i got to work.



edit: and heres the code that should, but doesnt :(



Grisu(Posted 2006) [#4]
Thanks Diablo for your try.

I did similar stuff without any working result.

I simply want to give the windowed (non gui) app a maximise button and be able to check this. If pressed the app should change gfx mode to fullscreen.

Strict 

Local window:TGadget

window=CreateWindow("My Window",40,40,320,240)
	WaitEvent
	WaitEvent
While True
	WaitEvent 
	Print CurrentEvent.ToString()

		Select EventID()
		Case EVENT_WINDOWSIZE
                        End 
		Case EVENT_WINDOWCLOSE
			End
	End Select
Wend


This example works with a gui win.
But it doesnt with "normal" gfx mode.


assari(Posted 2006) [#5]
Grisu, try this.
Go through my eventhook tutorial here to understand how all this works.
SuperStrict

Graphics 400,400,0,0,0

AddHook EmitEventHook, MyHook

Repeat
 WaitEvent()
 If EVENT_GADGETPAINT Then UpdateCanvas()
Forever
End

Function MyHook:Object(iId:Int,tData:Object,tContext:Object)
  Local Event:TEvent=TEvent(tData)

  If event.id<>1027 Then 'do not print Mouse Move event - too distracting 
     Print " event id="+event.id+":"+Hex$(Event.ID)
  EndIf

  Select event.id
  Case EVENT_APPTERMINATE 'event.id=$103 
     Notify "QUIT"
     End
  End Select

  Return tData

End Function

Function UpdateCanvas:Int()
     Cls
     SetColor Rnd(255),Rnd(255),Rnd(255)
     DrawRect 10,10,100,150
     Flip
End Function



Grisu(Posted 2006) [#6]
THis does not help me with the maximise button.

Strict

Extern "win32"
	Function GetActiveWindow%()
End Extern

Graphics 800,600,0
Local hWnd% = GetActiveWindow()
enableMaximize( hwnd% )

Repeat
 Select WaitEvent()
 Case EVENT_APPTERMINATE 'event.id=$103 
    End
 End Select

Forever
End

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


I "simply" want this app to go fullscreen when the button is clicked.


Diablo(Posted 2006) [#7]
here you go grisu, enjoy:



Grisu(Posted 2006) [#8]
Perfect, that's what I was after!

I have made a cleaner example with both minimize and maximize buttons and put this into the code archive for everyone to use:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1595

Thanks a lot!!!


Diablo(Posted 2006) [#9]
oh btw if you want to know if the window is minimized you can use IsIconic just like IsZoomed (mabey make it not update while minimized).

EDIT: OH you did :D that'll teach me


Grisu(Posted 2006) [#10]
Well "Appsuspended()" can be found in the bmx docs. :)
I dug there quite long. But sadly the docs lack of examples.