neotreksoftware.com
Example 1: Formwindow
Here is an example of how to get started with programming an application in
Gfa Basic for 32 bit Windows. This code can be copied directly into your
Gfa Basic editor.
Starter application shell formwindow gb32 example 1:
Click here to downloading formwindow.zip example 1 with 2 icon bitmaps
Formwindow is a new program with a window interface
as well as a windows menu and a windows toolbar
containing two buttons with loaded 16x16 images
like this:

This is the formwindow pasteable to editor code listing:
'formwindow
'Gfa basic pages example 1
'Starter application shell template Gfa Basic 32
'Allan Shura
'Ocx listing with dynamic forms as coded
//new application window
Form Formwindow //Window Ocx Form binding
AutoRedraw = 1 //redraw the window automatically
//Imagelist
Ocx ImageList iml //2 images loaded from file
//iml.MaskColor = colBtnFace //unused property
iml.ImageWidth = 16 //x pixel
iml.ImageHeight = 16 //y pixel
//add to imagelist a loaded from file picture
'**note: download the example images in the zip file
'**or load your own button images to place in the
'** form editor if you are using the paste code
'**or a yellow arrow error marker will apear here.
'*to activate the next two lines remove the
// comment markings
// .ListImages.Add , , LoadPicture(":btn1_i")
// .ListImages.Add , , LoadPicture(":btn2_i")
//the images are for toolbar buttons
//and these are given the names
//enumerated within a list.
Public Enum btn1_i=1, btn2_i=2
//Toolbar
Ocx ToolBar tb //toolbar Ocx to put on buttons
Public Enum btn1=2, btn2=4
//enumerate the button indexes
.Appearance = basNormal //bas3d
.ImageList = iml //add buttons
tb.Buttons.Add , , , 3 //spacer
tb.Buttons.Add , , , 0, btn1_i
tb.Buttons.Add , , , 3 //spacer
tb.Buttons.Add , , , 0, btn2_i
tb.Buttons.Add , , , 3 //spacer
//give text to the tooltip on mouseover
tb.Buttons(btn1).ToolTipText = "Button 2"
tb.Buttons(btn2).ToolTipText = "Button 4"
//Statusbar
Local sbtext
Ocx StatusBar sb
sb.Add , , "Status", sbtext
//This starter application uses the Gfa Basic
//Menu Array with the declared string array
//menu1$() loaded into the Gfa internal
//MENU() array in Gfa Basic native syntax
//Menus can also otherwise be created with
//other styles of programming such as C style
//in Gfa Basic.
//Menu
//the & ampersand is used for underscore
Data File ,&Open,
Data Edit ,&New,*/
Global Int m_item = 5
Global menu1$(m_item)
m_item = -1
Do
m_item ++ //c style increment
Read menu1$(m_item)//reading the string Data
Until InStr(menu1$(m_item), "*/") //to the array
menu1$(m_item) = ""
Menu menu1$()
Do //recieve messages until closing
@menu1 //call menu1 event Procedure
DoEvents
Until Me Is Nothing
Sub tb_ButtonClick(btn As Button)
//event message handler
//If there is a message sent by
//the toolbar buttons to windows
Message "Message: Toolbar Button ", btn.Index
EndSub
Procedure menu1
//menu windows event handler
Local c% = MENU(0), m1%, m2&, m3$, ms$
If c% And c% <= m_item
//If there is a message sent by the menu to windows
Message "Message: Menu Item " + Str$(MENU(0)), ms$
EndIf
Return
www.neotreksoftware.com