HMG
xBase Development System For Windows
TUTORIAL
Your First HMG Program
#include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; END WINDOW ACTIVATE WINDOW Win_1 Return DEFINE WINDOW command: Will create the main window for the program. Win_1: Is the name of the window. AT 0,0: Indicates the window position (row=0,col=0) WIDTH 400: Means that the window will have 400 pixels width. HEIGHT 200: Means that the window will have 200 pixels height. TITLE 'Hello World!': Indicates the text in the window title bar. MAIN: Indicates that we are defining the main application window ACTIVATE WINDOW Form_1: Will show the window and start the event
#include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU END WINDOW ACTIVATE WINDOW Win_1 Return As you can see it is pretty easy and intuitive. All the main menu stuff will be between DEFINE MAIN MENU / END MENU statements. You can use as popups as you need and you can nest it without any limit.
You can optionally add a title (passed as the second parameter)
@ 100,10 LABEL Label_1 VALUE 'This is a Label!' @ 100,10 means that the text will be showed at row 100 , column 10 (remember that the measurement unit is the pixel) Label_1 is the name of the control (we will identificate by this name) VALUE clause indicates the initial value of the control when created. #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; @ 100,10 LABEL Label_1 VALUE 'This is a Label!' END WINDOW ACTIVATE WINDOW Win_1 Return
@ 40 , 120 TEXTBOX Text_1 If you want to get numeric data, just add NUMERIC clause: @ 80 , 120 TEXTBOX Text_2 NUMERIC If you want to indicate an editing mask, you can use the INPUTMASK clause. @ 120 , 120 TEXTBOX Text_2 NUMERIC INPUTMASK '9999.99' #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU
@ 40 , 120 TEXTBOX Text_1 END WINDOW ACTIVATE WINDOW Win_1 Return
@ 180, 120 CHECKBOX Check_1 We add it to the program, along with new menu options to set or retrieve its value #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU END POPUP @ 100, 120 CHECKBOX Check_1 CAPTION 'Check Me!' END WINDOW ACTIVATE WINDOW Win_1 Return
The best way to go is such cases is the RadioGroup control. @ 80, 120 RADIOGROUP Radio_1 OPTIONS {'Option 1','Option 2','Option 3'} #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU END POPUP @ 80, 120 RADIOGROUP Radio_1 OPTIONS {'Option 1','Option 2','Option 3'} END WINDOW ACTIVATE WINDOW Win_1 Return
One of them is the ListBox Control @ 10, 10 LISTBOX List_1 ITEMS {'Option 1','Option 2','Option 3'} Using a Listbox, you can add, change or remove items at runtime. #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU @ 10, 10 LISTBOX List_1 ITEMS {'Option 1','Option 2','Option 3'} END WINDOW ACTIVATE WINDOW Win_1 Return
@ 10, 10 COMBOBOX Combo_1 ITEMS {'Option 1','Option 2','Option 3'} Using a Combobox, is similar to ListBox. #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU @ 10, 10 COMBOBOX Combo_1 ITEMS {'Option 1','Option 2','Option 3'} END WINDOW ACTIVATE WINDOW Win_1 Return
@ 10,10 BUTTON Button_1 CAPTION 'Click Here!' ACTION MsgInfo('Button Clicked!') #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; @ 10,10 BUTTON Button_1 ; END WINDOW ACTIVATE WINDOW Win_1 Return
@ 10,10 BUTTON PictureButton_1 ; #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; @ 10,10 BUTTON PictureButton_1 ; END WINDOW ACTIVATE WINDOW Win_1 Return The optional tooltip clause, causes that a small window with an explanatory text be displayed when the mouse pointer stays over the control for a few seconds. You can use this clause with most HMG controls. Button + CheckBox = CheckButton The CheckButton control, acts like a checkbox, but looks like a button. Like buttons, It comes in two flavors: Text and Graphical. @ 10,10 CHECKBUTTON CheckButton_1 ; @ 50,10 CHECKBUTTON CheckButton_2 ; #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU @ 10,10 CHECKBUTTON CheckButton_1 ; @ 50,10 CHECKBUTTON CheckButton_2 ; END WINDOW ACTIVATE WINDOW Win_1 Return
@ 10,10 DATEPICKER Date_1 #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU @ 10,10 DATEPICKER Date_1 END WINDOW ACTIVATE WINDOW Win_1 Return
@ 10,10 EDITBOX Edit_1 ; #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU @ 10,10 EDITBOX Edit_1 ; END WINDOW ACTIVATE WINDOW Win_1 Return
@ 10,10 IMAGE Image_1 ; #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU @ 10,10 IMAGE Image_1 ; END WINDOW ACTIVATE WINDOW Win_1 Return
@ 10,10 PROGRESSBAR Progress_1 ; #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU @ 10,10 PROGRESSBAR Progress_1 ; END WINDOW ACTIVATE WINDOW Win_1 Return Procedure DoTest() For i = 0 To 65535 Step 25 Return
@ 10,10 SPINNER Spinner_1 ; #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU @ 10,10 SPINNER Spinner_1 ; END WINDOW ACTIVATE WINDOW Win_1 Return
#include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU DEFINE TAB Tab_1 ; PAGE 'Page 1' PAGE 'Page 2' END TAB END WINDOW ACTIVATE WINDOW Win_1 Return
#include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU DEFINE TOOLBAR ToolBar_1 BUTTONSIZE 80,80 FLAT BORDER BUTTON Button_1 ; BUTTON Button_2 ; BUTTON Button_3 ; END TOOLBAR END WINDOW CENTER WINDOW Win_1 ACTIVATE WINDOW Win_1 Return Nil
#include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU DEFINE STATUSBAR END WINDOW ACTIVATE WINDOW Win_1 Return
Browse control allows to show / edit database records in tabular format. #include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE MAIN MENU @ 10,10 BROWSE Browse_1 ; END WINDOW CENTER WINDOW Win_1 ACTIVATE WINDOW Win_1 Return Nil Procedure OpenTables() Procedure CloseTables() (*) To change this behavior (the default) you must change 'browsesync' setting using 'Set BrowseSync On' command.
Field Property: Stablishes the field that control is bounded to. #include "hmg.ch" DEFINE WINDOW Win_1 ; DEFINE TOOLBAR ToolBar_1 BUTTONSIZE 100,30 FLAT RIGHTTEXT BORDER BUTTON TOP ; BUTTON PREVIOUS ; BUTTON NEXT ; BUTTON BOTTOM ; BUTTON SAVE ; BUTTON UNDO ; END TOOLBAR @ 50,10 LABEL LABEL_1 VALUE 'Code:' @ 50,200 TEXTBOX TEXT_1; @ 80,200 TEXTBOX TEXT_2; @ 110,200 TEXTBOX TEXT_3; @ 140,200 DATEPICKER DATE_4 ; @ 170,200 CHECKBOX CHECK_5 ; @ 200,200 EDITBOX EDIT_6 ; END WINDOW Win_1.Text_1.SetFocus ACTIVATE WINDOW Win_1 Return Nil Procedure Refresh Win_1.Text_1.Refresh Return Procedure Save Win_1.Text_1.Save Return Procedure OpenTables Procedure CloseTables
#include "hmg.ch" Function Main DEFINE WINDOW Win_1 ; DEFINE SPLITBOX LISTBOX List_1 ; EDITBOX Edit_1 ; END SPLITBOX END WINDOW CENTER WINDOW Win_1 ACTIVATE WINDOW Win_1 Return Nil -- |