Creating a sub window

BlitzMax Modules Forums/Brucey's Modules/Creating a sub window

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.

How would i create it in the Oninit() then ShowModal it on the CreateAddPOSWindow function? because i tried it and it doesnt work.

I'd like to be able to do this so i can just end it from a different function, called by a button click on the window..

code:

SuperStrict

'import needed modules
Framework wx.wxApp
Import wx.wxFrame
Import wx.wxComboBox
Import wx.wxAui
Import wx.wxTextCtrl
Import wx.wxTreeCtrl
Import wx.wxSpinCtrl
Import wx.wxButton
Import wx.wxBitmapButton
Import wx.wxStaticText
Import wx.wxArtProvider
Import wx.wxColourDialog

'consts
Const wxDEFAULT_NO_RESIZE:Int = wxSYSTEM_MENU | wxMINIMIZE_BOX | ..
wxMAXIMIZE_BOX | wxCLOSE_BOX | wxCAPTION | wxCLIP_CHILDREN | wxBORDER_STATIC


'global vars




'App stuff
Type MyApp Extends wxApp

	Field frame:myFrame
	Field box1:wxComboBox

	Method OnInit:Int()
		
		'create window and show it
		frame = myFrame(New myFrame.Create(,,"POS Tracker", 200, 200, 800, 600, wxDEFAULT_NO_RESIZE))
		frame.show()
		
	
		'return successful
		Return True
	
	End Method

End Type

'The window
Type myFrame Extends wxFrame

	'fields
	
	
	'constants
	Const menu_Exit:Int = 201
	Const tb_Add:Int = 202
	Const tb_Remove:Int = 203
	Const win_posadd:Int = 204
	Const but_ok1:Int = 205
	
	'on start up...
	Method OnInit()
		
		
		'MENU BAR
		Local mb:wxMenuBar = New wxMenuBar.Create()
		
		Local fileMenu:wxMenu = New wxMenu.Create()
		fileMenu.Append(menu_Exit, "Exit")
		
		mb.Append(fileMenu,"File")
		SetMenuBar(mb)
		
		'STATUS BAR
		CreateStatusBar()
		SetStatusText("Welcome to the POS Tracker!")
		
		'toolbar
		Local tb1:wxToolBar = New wxToolBar.Create(Self, wxID_ANY, ,, ,, wxTB_FLAT | wxTB_NODIVIDER | wxTB_HORZ_TEXT)
		tb1.SetToolBitmapSize(20, 20)
		tb1.AddTool(tb_Remove, "Remove POS", wxArtProvider.GetBitmap(wxART_ERROR,,20,20))
		tb1.AddTool(tb_Add, "Add POS", wxArtProvider.GetBitmap(wxART_ADD_BOOKMARK,,20,20))
		tb1.Realize()
		
		'Create the Add POS sub window
		Local Addpos:wxDialog = New wxDialog.Create_(Self,wxID_ANY , "Add POS",-1 ,-1 , 500, 300, wxSTAY_ON_TOP|  wxDEFAULT_DIALOG_STYLE)
		Local ok:wxButton = New wxButton.Create(Addpos,but_ok1,"Ok")	
		
		'EVENT HANDLING
		Connect(menu_Exit, wxEVT_COMMAND_MENU_SELECTED, OnExit)
		Connect(tb_Add, wxEVT_COMMAND_TOOL_CLICKED, AddPOSWindow)
		Connect(but_ok1, wxEVT_COMMAND_BUTTON_CLICKED, AddPOS)
		
	End Method
	
	'a function to handle exiting...
	Function OnExit(event:wxEvent)
	
		wxFrame(event.parent).Close(True)
		
	End Function
	
	'show ADD POS window
	Function AddPOSWindow(event:wxEvent)
	
		Addpos.ShowModal()
		
	End Function
	
	'Adds a POS / ends the the dialog
	Function AddPOS(event:wxEvent)
	
		Addpos.EndModal()
	
	End Function
	

End Type



'run the program
New MyApp.run()


Thanks for all the help so far.