Issue inheriting TGadget properties

BlitzMax Forums/BlitzMax GUI Programming/Issue inheriting TGadget properties

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.

Hello,

I am new to Blitzmax so Im still learning.....anyway.

I am trying to create a Tile map editor gui using Maxgui. Im am creating a type for a window and then I am trying to create a canvas based on the dimensions of that window object.

The problem is that it appears that the MainWindow object I created is null when I try and use a gadget function on it.

If you create an object that extends the base Tgadget class doesnt it inherit all of its properties\methods\functions?

Once it gets to the line of code to create the canvas it says attempt to access field or method of null object.

Here is my code;

Global MainWindow:TNewWindow = New TNewWindow
MainWindow.Create("The Main Window",wx,wy,GAME_WIDTH,GAME_HEIGHT,MainWindow)

Global newcanvas:Tgadget= CreateCanvas(0,0,ClientWidth(Mainwindow),ClientHeight(Mainwindow),Mainwindow)

Repeat
Mainwindow.UpdateState()

Until AppTerminate()

End

Type TMyGadget Extends TGadget

Field Tgad:TGadget
Field Tgadx:Int
Field Tgady:Int
Field Tgadh:Int
Field Tgadw:Int
Field TgadParent:Tgadget

'Method UpdateState() Abstract



End Type

Type TNewWindow Extends TMyGadget

Field Tgad:TGadget

Method Create(wCaption:String,wX:Int,wY:Int,wWidth:Int,wHeight:Int,wParent:TNewWindow)

Tgad= CreateWindow(wCaption,wX,wY,wWidth,wHeight,,WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_MENU | WINDOW_STATUS)
'Local text$= "My current size (w,h) is " + ClientWidth(Tgad)+ "," + ClientHeight(Tgad)
'SetStatusText Tgad, text$


End Method


Method UpdateState()

'AddHook EmitEventHook, Mainhook


WaitEvent()
Select EventID()

Case EVENT_WINDOWCLOSE
' FreeGadget TileCanvas
End

' Case EVENT_WINDOWSIZE
'
' ResizeWindows


' Case EVENT_MOUSEMOVE



' Case EVENT_GADGETPAINT
' SetGraphics CanvasGraphics(Maincanvas)
' SetViewport 0, 0, ClientWidth(Mainwindow), ClientHeight(Mainwindow)
' Cls

Case EVENT_APPTERMINATE
End
End Select

'Flip

End Method

End Type