Building a HMG project in a few steps:
Please refer to the HMG-IDE page when needed.
Step 1 :
Download latest release of HMG package and run HMG setup wizard. You can change default location and name of HMG; and your HMG directory structure will be like this:
Note : This structure is for HMG 3.0.39; later may change.
Attention to the HARBOUR and MINGW folders. This means that you haven’t download or install neither Harbour nor MinGW. HMG setup wizard include its for your convenience.
Attention also IDE directory. HMG-IDE also included into package; you haven’t any more download process for it.
Step 2:
Run HMG-IDE.
Step 3:
Select File\New Project from menu or simply click New Project button.
Select ( make one new if necessary ) a folder and give a name your first project, say “HelloWord”. You may use long file name; but beware including spaces and special character in your full file name.
You will see your project name ( with .hbp extension) in title of Project Browser window.
Whenever you start a new project, IDE builds a “Main.prg” and a “Main.fmg” for you and open automatically:
#include <hmg.ch>
Function Main
Load Window Main
Main.Center
Main.Activate
Return
You may continue working with these two main files. For following a sample/tutor it’s not mandatory using file (project, module, form ) names exactly. F.e. you can apply “HelloWord” sample by using “Main.prg” instead of “HelloWord.prg”.
If your project does not include a form ( .fmg file ) simply exclude default main form (“main.fmg” ) by using “Project\ Delete File” menu command. In this case you have delete Load, Center and Activate form command lines in the “Main.Prg”.
Caution : Use carefully “Delete File”; it’s not only “Exclude from project”, also delete selected file from disk.
If you prefer using module/file name in the sample or your own, you may exclude (delete) main module ( “Main.prg” ) too.
Step 4:
If you prefer construct your own module, select Project\New Module from menu or simply click “New Module” button.
Give a name for your first module ( .prg ) file; say again “HelloWord”. You can easliy see that IDE give .prg extension your module file name and if it is first module of your project, will set and marks it as “(Main)”. Afterwards you can easliy change your main module by selecting any of your modules and then selecting “Project\Set Module As Main” from menu. Every project must have one and only one main module.
Step 5:
Double click on your module name in the project browser. This will open your module file for editing. HMG has a default source code editor defined. You can change default module editor in “Preference” page by selecting “Tools\Preferences” from menu.
Whenever you open a new module file you will see this line on the top of page:
#include <hmg.ch>
This line is standard first line of all HMG modules. Unless you want build a project for console mode only, this line is necessary.
Step 6:
After this first, enter below lines to your program :
Function Main
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 200 ;
TITLE ‘Hello World!’ ;
MAIN
END WINDOW
ACTIVATE WINDOW Win_1
Return
Step 7:
Save your program file and then build and run your project by selecting “Project\Run” from menu or simply click “run” button.
That is all !
Analysis of program :
Function Main statement : Every HMG project must have one and only one “main” function ( or procedure ) and its name must be “main”.
DEFINE WINDOW command: Define the main window for the program.
Win_1: Is the name of the window.
AT 0,0: Indicates the window position (row=0,column=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 (a main window is required for all Harbour MiniGUI applications)
ACTIVATE WINDOW Win_1: Will show the window and start the event loop.
Return statement : Indicate the end of function “main”.