Building a HMG project in a few steps
Step 1 :
Download latest release of HMG package and run HMG setup wizard.
Caution : Don't change default install location ( c:\hmg ). Otherwise you'll have reconfigure batch and resource files by yourself. The default folder structure is like this :
Attention to the HARBOUR and MINGW folders. This means that you haven't download or install neither Harbour nor MinGW. HMG setup wizard include theme for your convenience.
Step 2 :
Download latest release of HMG-IDE, extract IDE Setup vizard from downloaded .zip file and run. Location of IDE isn't important; you can install anywhere you like.
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 .hpj 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 this new form automatically. 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 ) simple exclude default main form ( "main.fmg" ) by using "Project\ Exclude Item" menu command. In this case you have delete Load, Center and Activate Form command lines in the "Main.Prg".
If you prefer using module/file name in the sample or your own, you may exclude main modul ( "Main.prg" ) too. You my want also delete "Main.Prg" and "Main.Fmg" files from your project folder.
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.
Double click on your module name in the project browser. This will open your module file for editing. Default source code editor is NotPad. 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:
This line is standard first line of all HMG modules. Unless you want build a project for console mode only, this line is necessary.
After this first, enter below lines to your program :
Code: Select all
Function Main DEFINE WINDOW Win_1 ; AT 0,0 ; WIDTH 400 ; HEIGHT 200 ; TITLE 'Hello World!' ; MAIN END WINDOW ACTIVATE WINDOW Win_1 Return
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: 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 (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".
As you see, by very little seven steps and with a few ( in fact only five ) code lines a full functional win32 program builded.
This is HMG Power !