Center a windows under another

BlitzMax Forums/BlitzMax GUI Programming/Center a windows under another

Hi :)

Here is a function to center a window under another one.

Use as you want :)


Usage :

Center_window(AddnewpasswordWin,KmpWin)

' -----------------------------------------
' Function to center a window under another
' -----------------------------------------
Function Center_window(Source:TGadget,Parent:TGadget)
	Local w:Int=GadgetWidth(Parent)
	Local h:Int=GadgetHeight(Parent)
	
	Local x:Int=(GadgetX(Parent)+w/2)-(GadgetWidth(Source)/2)
	Local y:Int=(GadgetY(Parent)+h/2)-(GadgetHeight(Source)/2)
	
	SetGadgetShape(Source,x,y,GadgetWidth(Source),GadgetHeight(Source))
End Function


Use as you want :)


Thanks Filax.
I think I'll put it in the Code Archives and pretend it was mine. :)

Lol tonyg :) ! but i don't see max gui section under code archive ?

Mark can you add a new section called "max gui" under code archive ?