new to GUI programming

General FreeBASIC programming questions.
Post Reply
rmann05
Posts: 50
Joined: May 31, 2005 16:02
Location: Florida
Contact:

new to GUI programming

Post by rmann05 »

Hello. I'm new to GUI programming, so since FreeBASIC doesn't have it's own GUI library, I'm trying to use Wx-C. I'm starting out with just a simple program that displays an edit box and has an OK button. When I compile and run the program, and type something in the editbox, I can't tab out of the editbox to the OK button. What am I doing wrong? My source code is pasted below.
#include "wx-c/wx.bi"
#define wxclose_box &h1000
#define false 0
#ifndef true
#define true not(false)
#endif
option escape
option explicit
dim shared a as string
declare sub app_oninit()
declare sub app_onexit()
declare sub button0_event(byval event as wxevent ptr, byval ilistener as long)
dim shared wx_app as wxapp ptr, wx_frame as wxframe ptr
sub app_oninit()
wx_frame=wxframe()
wxframe_create(wx_frame,0,-1,"GUI Test with Wx-C",wxsize(440,312),wxsize(378,384),wxdefault_frame_style or wxclose_box,"frame")
wxwindow_setbackgroundcolour(wx_frame,wxsystemsettings_getcolour(15))
dim minutetext as wxtextctrl ptr
minutetext=wxtextctrl()
wxtextctrl_create(minutetext,wx_frame,-1,"How many minutes?",wxsize(25,0),wxsize(150,20),0,0,0)
dim button0 as wxbutton ptr
button0=wxbutton()
wxbutton_create(button0,wx_frame,-1,"&OK",wxsize(25,45),wxsize(-1,-1),0,0,0)
'below code calls the function when the button is clicked.'
wxevthandler_proxy(button0,@button0_event)
wxevthandler_connect(button0, wxevent_evt_command_button_clicked(),-1,-1,0)
wxwindow_setautolayout(wx_frame,true)
wxwindow_show(wx_frame,1)
end sub
sub app_onexit()
wxapp_onexit(wx_app)
end sub
sub button0_event(byval event as wxevent ptr, byval ilistener as long)
wxmsgbox(0,"Exiting","This window will now close.",0,wxsize(-1,-1))
end
end sub

wx_app=wxapp()
wxapp_registervirtual(wx_app,@app_oninit,@app_onexit)
wxapp_run(0,0)
cha0s
Site Admin
Posts: 5319
Joined: May 27, 2005 6:42
Location: USA
Contact:

Post by cha0s »

next time you post, highlight all of your code before hitting submit, and then click the "Code" button on top, its much easier to read:

Code: Select all

#include "wx-c/wx.bi"

#define wxclose_box &h1000

#define false 0

#ifndef true
#define true not(false)
#endif

option escape
option explicit

dim shared a as string

declare sub app_oninit()
declare sub app_onexit()
declare sub button0_event(byval event as wxevent ptr, byval ilistener as long)

dim shared wx_app as wxapp ptr, wx_frame as wxframe ptr

sub app_oninit()


wx_frame=wxframe()
wxframe_create(wx_frame,0,-1,"GUI Test with Wx-C",wxsize(440,312),wxsize(378,384),wxdefault_frame_style or wxclose_box,"frame")
wxwindow_setbackgroundcolour(wx_frame,wxsystemsettings_getcolour(15))
dim minutetext as wxtextctrl ptr
minutetext=wxtextctrl()
wxtextctrl_create(minutetext,wx_frame,-1,"How many minutes?",wxsize(25,0),wxsize(150,20),0,0,0)
dim button0 as wxbutton ptr
button0=wxbutton()
wxbutton_create(button0,wx_frame,-1,"&OK",wxsize(25,45),wxsize(-1,-1),0,0,0)
'below code calls the function when the button is clicked.'
wxevthandler_proxy(button0,@button0_event)
wxevthandler_connect(button0, wxevent_evt_command_button_clicked(),-1,-1,0)
wxwindow_setautolayout(wx_frame,true)
wxwindow_show(wx_frame,1)


end sub


sub app_onexit()


wxapp_onexit(wx_app)


end sub


sub button0_event(byval event as wxevent ptr, byval ilistener as long)


wxmsgbox(0,"Exiting","This window will now close.",0,wxsize(-1,-1))
end


end sub


wx_app=wxapp()
wxapp_registervirtual(wx_app,@app_oninit,@app_onexit)
wxapp_run(0,0)
edit: formatting wouldnt hurt either x.x sorry if i sound nazi but dude, that is painful
Post Reply