Null Max2dDriver

BlitzMax Forums/BlitzMax GUI Programming/Null Max2dDriver

I'm trying to add a map to my GUI, but I've run into a problem... Its giving me the usual error.
Unhandled Exception:Attempt to access field or method of Null object
But its reporting it on _max2dDriver.Cls within Cls().

'This BMX file was edited with BLIde ( <a href="http://www.blide.org" target="_blank">http://www.blide.org</a> )
SuperStrict

Module ncg.io_gui

ModuleInfo "Name: EoN IO"
ModuleInfo "Description: Engine of New Creation IO Module"
ModuleInfo "License: "
ModuleInfo "Authors: New Creation Games"
ModuleInfo "CustomAttr:"

Import brl.Win32MaxGUI
Import brl.RamStream
Import BRL.BMPLoader
Import brl.EventQueue
Import brl.max2d
'Import maxgui.drivers

Import brl.PNGLoader
Import brl.TGALoader
Import brl.JPGLoader

Global MainWindow:TGadget = CreateWindow("Main", 100, 100, 800, 600, Null, WINDOW_TITLEBAR)

'Global Map:TImage = LoadImage(AppDir + "/Map.bmp")
Global Map_Canvas:TGadget = CreateCanvas(0, 460, 100, 100, MainWindow)

Global InLabel:TGadget = CreateLabel("", 200, 0, 590, 20, MainWindow, LABEL_CENTER)
Global InBox:TGadget = CreateListBox(200, 20, 590, 400, MainWindow)

Global InfoPanel:TGadget = CreatePanel(0, 0, 200, 120, MainWindow, PANEL_BORDER)
Global NameLabel:TGadget = CreateLabel("Name: Sjoerd Daniel Maximus the Third", 0, 0, 200, 20, InfoPanel)
Global LocationLabel:TGadget = CreateLabel("Location: Council Chambers", 0, 20, 200, 20, InfoPanel)
Global AimLabel:TGadget = CreateLabel("Aim: 70%", 0, 40, 200, 20, InfoPanel)
Global AvoidLabel:TGadget = CreateLabel("Avoid: 30%", 0, 60, 200, 20, InfoPanel)
Global WeaponLabel:TGadget = CreateLabel("Weapon: E-11 Blaster Rifle", 0, 80, 200, 20, InfoPanel)
Global LifeLabel:TGadget = CreateLabel("Life:", 0, 100, 200, 20, InfoPanel)

Global InfoLog:TGadget = CreateListBox(200, 420, 590, 100, MainWindow)

Function In:String(Msg:String, Map:TImage, IsChoice:Int = True, Choices:TList)
	Local Temp_String:String
	Local ExitTime:Int = False

	InBox.Clear()
	For Temp_String = EachIn Choices
		AddGadgetItem(InBox, Temp_String)
	Next
	SetGadgetText(InLabel, MSG)
	RedrawGadget(Map_Canvas)
	
	While Not ExitTime = True
		WaitEvent()
		Select EventID()
			Case EVENT_WINDOWCLOSE
				End
			Case EVENT_GADGETACTION
				If SelectedGadgetItem(InBox) <> - 1
					ExitTime = True
				End If
	 		Case EVENT_GADGETPAINT
				SetGraphics(CanvasGraphics(Map_Canvas))
				Cls
				DrawImage(Map, 0, 0)
				Flip
		End Select
	Wend
	Return GadgetItemText(InBox, SelectedGadgetItem(InBox))
End Function


I'm guessing that it's because you failed to import BRL.D3D7Max2D and BRL.GLMax2D.

Just a note: that is a horrible implementation for a module.

Khomy Prime:
I included the code to import those, but nothing happened different, same problem.

Plash:
I obviously didn't include ALL the code... so there are some reasons for some manipulations. Another thing is that I'm still working on getting it functional, I've not even begun work on one aspect... I intend on getting it functional first, then pretty, and finally fast if necessary.

In any case, I'd be interested in knowing what's so wrong about it, and what you would do to fix it.. I'm aware that I'm using too many Globals and I intend on eliminating many of them, some however require direct manipulation in the main program.

A module should contain types/functions/features frequently used, you will probably run into some problems using the constant state of your gadgets, and the like, with the way it is.

Ah... Well I'm not exactly making a module per ce. Its more of a framework/engine/base on which to build a game... I'm mostly developing it for myself.

I included the code to import those, but nothing happened different, same problem.
Did you recompile the module..?

The changes wouldn't be implemented if I didn't. Anyway, yes I did.

Does it help if you add this line before the CLS:
SetViewport 0,0,GadgetWidth( Map_Canvas),GadgetHeight( Map_Canvas)

I've now tried that, nothing changed.
And I recompiled the module.