Example of OOP GUI App needed.

BlitzMax Forums/BlitzMax Beginners Area/Example of OOP GUI App needed.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

hi with the following code:
Strict

Type TTestApp

	Field Window:TGadget = CreateWindow("",0,0,640,480)
	Field Button:TGadget = CreateButton("BUTTON",0,0,100,20,Window)
	Field Canvas:TGadget = CreateCanvas(0,20,ClientWidth(window),ClientHeight(window)-20,window,PANEL_BORDER)
	
	Method New()
		AddHook EmitEventHook,eventhook,Self
		Button.SetLayout(1,0,1,0)
		Canvas.SetLayout(1,1,1,1)
	EndMethod	
	
	Function eventhook:Object(id,data:Object,context:Object)
		If TTestApp(context) Then TTestApp(context).OnEvent TEvent(data)
		Return data	
	EndFunction
	
	Method OnEvent(event:TEvent)
		Select event.id
		
			Case EVENT_WINDOWCLOSE
				Select Event.Source
					Case window
						End
				End Select
				
			Case EVENT_GADGETACTION
				Select Event.Source
					Case Button
						Notify "You pressed the button"
				EndSelect
			
			Case EVENT_GADGETPAINT
				Select Event.Source
					Case Canvas
						SetGraphics(CanvasGraphics(canvas))
						SetViewport(0,0,ClientWidth(canvas),ClientHeight(canvas))
						Cls
						DrawText "TEST CANVAS",10,10
						Flip 0
				EndSelect
				
		EndSelect
	EndMethod
	
EndType


Global App:TTestApp = New TTestApp

While True
	WaitEvent()
Wend


should i not be able to do

Global App:TTestApp = New TTestApp
Global App2:TTestApp = New TTestApp


...although if i do it throws and error with the line?