Non-MaxGUI Resizable window?
BlitzMax Forums/BlitzMax Beginners Area/Non-MaxGUI Resizable window?| 
 | ||
| I tried googling this forum, and I found a few responses but couldn't understand how this is done. I want to know how I'd do this from scratch, anyone know of a tutorial? Do I "Include" the win32 API or something? Can blitzmax import and read raw c++ cpp and headers files or is there a guide to importing regular c++ libs for use in blitzmax maybe? anyway, MaxGUI is nice and whatever, but I dont know if I could figure them out. Graphics(params) seems very simple compared to working inside TGadgets which can become windows..... or 10 other things.. but im confused, do all TGadgets work inside one renderer element or what/ does it work off a heirchy of Gadgets, such as the first canvas TGadget or first TGadget which returns a canvas becomes the master rendering element that parents all the other child TGadget elements? anyway my original questions is how can I have a simple resizable window without using MAxGUI since I read its possible but didnt understand the responses. | 
| 
 | ||
| Here is a minimal solution with MaxGUI: This sample has only one window and inside a canvas, which can be used very simple: SuperStrict
Import MaxGUI.Drivers 
Global Window:TGadget=CreateWindow("TEST",100,100,400,400)
Global Canvas:Tgadget=CreateCanvas(0,0,1920,1080,Window)
Global MausHit%, MausX%, MausY%
CreateTimer 10
While WaitEvent()
   Select EventID()
	Case EVENT_KEYDOWN
			Print "KKeydown" + EventData()
	'Case EVENT_KEYUP
 
  	Case EVENT_TIMERTICK
			MainLoop
   	Case EVENT_GADGETPAINT
			MainLoop		
   	Case EVENT_WINDOWCLOSE
			QuitMe
   	Case EVENT_APPTERMINATE
			QuitMe
	Case EVENT_MENUACTION
  			RedrawGadget Canvas
	'Case EVENT_GADGETACTION
  	Case EVENT_MOUSEDOWN 
			MausHit=1
	Case EVENT_MOUSEUP
			MausHit=0
 	Case EVENT_MOUSEMOVE 
			MausX=EventX()
			MausY=EventY()
 	'Case EVENT_MOUSELEAVE
	Case EVENT_WINDOWSIZE
			ResizeMe
	Default
		Print  "EVENT= " + 		EventID()
	End Select
Wend
Function MainLoop()
			SetGraphics CanvasGraphics(Canvas)
			SetAlpha 1
			SetColor 255,255,255
			SetScale 1,1
			Cls
			'**** your code here: **********************************************************			
				For Local i%=0 To 100
					DrawOval Rand(0,GadgetWidth(Window)), Rand(0,GadgetHeight(Window)),5,5
				Next
				SetColor 255,0,0
				If MausHit=1
					Print "Maus " + MausX +" " + MausY
					DrawOval MausX-15,MausY-15,30,30
				EndIf
			'*********************************************************		
			Flip 0
End Function
Function QuitMe()
	FreeGadget Canvas
   	End
End Function
Function ResizeMe()
		SetGadgetLayout Canvas , 1,1,1,1
		SetGadgetShape Canvas, 0 , 0 , GadgetWidth(Window) , GadgetHeight(Window)
		RedrawGadget Canvas
End Function
Put your drawing code between CLS and FLIP like your are used to do. The DEFAULT section helps to to identify unkonwn events | 
| 
 | ||
| The TGadget type is extended by each of the MaxGUI "drivers" (which are modules that contain platform-specific code), and these extended gadgets represent actual gadgets of the native UI system (on Windows I think it's based on Kernel32, User32 and GDI32). The gadgets that your MaxGUI application uses are always native, wrapped in that TGadget abstraction. Without using MaxGUI, to get a resizable window you would use an Extern "win32" block to get the system functions necessary to create those UI objects, which is the same that MaxGUI does. So you should use MaxGUI because it'll save you work. But you can "hack" into it to get the behaviour you want: the specialised TWindowsGadget type has a hWnd field, for example, that you can obtain with QueryGadget() and use with native functions. | 
| 
 | ||
| On using external libraries, take a look at how other modules are doing it. They Import the source files and use Extern: https://github.com/maxmods/bah.mod/blob/master/cairo.mod/externs.bmx You need MinGW configured properly to be able to compile external source files. |