This is my approach in learning HMG way back in 2007:
1. I don't go into programming right away. I set aside time to first read HMG manual, how it is organize and how I would quickly cross reference the manual. My goal is to familiarize myself with the documentation so I know where to find them.
2. Then I check how Harbour (without HMG and no third party clipper library), can compile pure Clipper code. Then I wrote code to to test RDD (DBFCDX) from my old application, basically the routine that opened the tables, replaced field contents, seek, delete, array handling, numeric calculation, date calculations. All those are done without data entry screen (because that will be the GUI portion). So when I found out that Harbour can do all those, I am quite sure that I only needed to learn how to manage the GUI portion and learn the technique of interfacing HMG+Harbour. For Harbour reference I used Clipper reference books and the NGs and reading those CHANGELOG.TXT of Harbour, HMG and HMG Extended to at least piece together what's going on and to get an insight and somehow connect to the developers mind (those logs are their first hand account, just like a diary if you will).
3. To learn HMG I used <hmgInstallDir>\SAMPLES\Basics\MAIN_DEMO\DEMO.PRG. Of course if you are looking for something you've needed a demo that showcase everything (at least most of it if not all).
4. On the third week I have my old app reborn in HMG+Harbour, though its not fully bug free but I'd be able to smooth them out later on. The rest is history.
5. Since HMG is an open source and evolving, I/we should understand that there won't be a book like manual anytime soon. So you need to read the include files and the corresponding c and prg modules of the library (which became my second HMG reference). You can do this to further enhanced your knowledge.
6. Use modular programming as much as possible. Since Clipper days I wrote code in modular way (if possible) so when I moved to HMG I basically change the Text User Interface with GUI or forms. Now the @ SAY commands becomes LABEL and @ GET becomes TEXTBOX plus the COMBOBOX, RADIOGROUP, CHECKBOX, etc.
7. Coding in GUI means to forget about SAVESCREEN() and RESTSCREEN(). You need to have a new paradigm which is event driven. Restrict the user to a form by using modal or even then you can prevent it by attaching procedures to ON RELEASE and ON INTERACTIVECLOSE.
8. HMG Controls resembles VB but not exactly the same. So in essence the key in learning HMG is understanding HMG controls and objects EVENTS and PROPERTIES which is contained in the manual. Those are the points to where you can interface your Clipper knowledge towards Harbour and HMG. Later on if you think that you have the feel of it, then exploit to your advantage.
1. Event driven programming is not the same as procedural programming so don't let the frustration bugs you down. See it as a challenge to be overcome. Everybody (in this [HMG] Forum, HMG Extended and Harbour users) did it that way and there's no reason that you can't.
2. Program Control Flow: In order to control your program flow, learn or read the HMG manual regarding the EVENTS or METHODS (same as events) and PROPERTIES of a control that you intended to use. Most of HMG control objects have a common EVENTS like ON LOSTFOCUS, ON GOTFOCUS and ON CHANGE. Forms (Windows) have much more EVENTS like ON INIT, ON GOTFOCUS, ON SIZE, ON MAXIMIZE, ON RELEASE, ON INTERACTIVE CLOSE (windows close box), etc. Those events are functions, procedures or code blocks that you attached to them called branching out or (threads). Threads and subroutines has a thin red-line difference but equally alike. So do not release the window from triggered events unless that's your intention. Remember to use setfocus (to a form or to a control object) if you need to and really you needed to do that to control the program flow.
So before you code plan ahead and determine how are you going to control those EVENTS that ultimately defines the behavior of your application. Those events are our/your friend as well as a foe. It will be easier to go over with the samples and start building from there. Eventually incorporate your routines from simple and progressively going to a complex one.
Use HMG-IDE to compile and debug and to watch how the codes are executed one after the other. Step through it by using F8. Insert ALTD() to any position in your source code to pause or stop the debugger. To run in debugger mode from HMG-IDE click Project->Debug (select debug).
3. If your program does different than your intended goal or design, create a small test version and test if they are the same. Almost always the problem is in your code and not in the library. Otherwise post them to HMG Forum describing your problem in details.
IMHO, HMG and HMG Extended has a short learning curve but that depends on how are you going to approach your migration to HMG. From Clipper I believed that would be about the GUI handling. From FoxPro (DOS/Windows) read Harbour's RDD, AEVAL(), EVAL(), functions and code blocks, variable types and data types and HMG manual.
Learning is fun and I am quite sure that as you progress you can code a simple straight forward form without using the form designer. For me I define the labels height as 18 and textboxes as default height which is 24 and default width. I added 3 on the labels row based on the row that I used on textbox control like the code snippet below:
Code: Select all
DEFINE WINDOW frmGUI_1 AT 0,0 WIDTH 409 HEIGHT 185; @ 33, 30 LABEL lblCode OF frmGUI_1 VALUE "&Code:"; ACTION Nil WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9 @ 30,120 TEXTBOX txbCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( COLTBL->F1 ) READONLY WIDTH 100; FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 10 UPPERCASE; ON LOSTFOCUS CheckEventLostFocus( cMode ) @ 63, 30 LABEL lblDesc OF frmGUI_1 VALUE "&Name:"; ACTION Nil WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9 @ 60,120 TEXTBOX txbDesc OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( COLTBL->F2 ) WIDTH 250; FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 40 ON LOSTFOCUS CheckEventLostFocus( cMode ); ON CHANGE GUISaveButtonEnable()
HMG Tutorial by Giovanni Di Maria: http://www.elektrosoft.it/tutorials.asp
Kevin Carmody's HMG manual in CHM format: http://kevincarmody.com/hmg/DOC/
You can also visit HMG Extended (forked from HMG) at: http://www.hmgextended.com/
You can find more at Mr. Esgici's Blog at: http://vivaclipper.wordpress.com/
Sample HMG-IDE Configuration
Code: Select all
# HBMK2 : link script # Author: Danny Del Pilar # ################################# #include Paths incpaths=c:\hmg\include #library paths libpaths=c:\hmg\lib libs=valleylibs daleaidcommon #Resulting Executable Folder instpaths= #Build Options mt=yes inc=no head=native
Code: Select all
MAINICON ICON RES\SCFICON.ICO IMGTBEXIT BITMAP RES\EXIT.BMP IMGEXIT16 BITMAP RES\EXIT16.BMP IMGEXIT32 PNG RES\EXIT32.PNG IMGBKUP BITMAP RES\COMPRESS.BMP IMGCOMP32 PNG RES\COMPRESS32.PNG IMGRBRES BITMAP RES\RESTORE.BMP IMGRBRES32 PNG RES\RESTORE32.PNG IMGEXPLORE BITMAP RES\EXP.BMP IMGEXPLORE32 PNG RES\VIEW32.PNG IMGLOGOFF BITMAP RES\TBLOGOFF.BMP IMGLOGOFF16 BITMAP RES\LOGOFF16.BMP IMGPEOPLE BITMAP RES\PEOPLE.BMP IMGCOL16 BITMAP RES\TBCOLLECTION16.BMP IMGCOL32 JPG RES\COLLECTION32.JPG IMGCRED16 BITMAP RES\CREDITORS.BMP IMGCRED32 JPG RES\CREDITORS32.JPG SCFBANNER PNG RES\SCFBANNER2.PNG IMGDEP216 PNG RES\DEPOSIT2.PNG IMGEXP16 PNG RES\EXPENSES.PNG IMGEXP32 JPG RES\EXPENSES32.JPG IMGLOGIN PNG RES\scflogin.PNG IMGTBLOG PNG RES\scflogin32.png IMGCOLLECT PNG RES\money_bag2.png IMGDISB PNG RES\DISBURSE.PNG IMGDISB32 PNG RES\DISB32.PNG IMGLOANREG PNG RES\LOANREG.PNG IMGLOANREG32 PNG RES\loanregistry32.png DADEXIT BITMAP RES\EXIT20.BMP DADNEW16 BITMAP RES\NEW_FIELD16.BMP DADEDIT20 BITMAP RES\EDIT20.BMP DADDEL BITMAP RES\DELRECORD16.BMP DADPRINT16 BITMAP RES\PRINT16_2.BMP DADNEW BITMAP RES\NEW_FIELD.BMP DADEDITFIELD BITMAP RES\EDIT_FIELD.BMP DADCANCEL BITMAP RES\CANCEL.BMP DADOK BITMAP RES\OK.BMP DADPRINT BITMAP RES\PRINT.BMP DADFIND BITMAP RES\FIND.BMP DADSTRUCT BITMAP RES\STRUCT.BMP /*-------------------------- Metadata ----------------------------*/ 1 VERSIONINFO FILEVERSION 1,0,0,0 PRODUCTVERSION 1,0,0,0 BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" BEGIN VALUE "CompanyName", "La DALE-Aid® Creative Solutions" VALUE "FileDescription", "Cash Flow Lite Version 1.0" VALUE "FileVersion", "1.0" VALUE "InternalName", "SCF" VALUE "LegalCopyright", "Danny A. Del Pilar" VALUE "OriginalFilename", "scf.exe" VALUE "ProductName", "Cash Flow Lite Version 1.0 (Simple Cash Flow Management System)" VALUE "ProductVersion", "1.0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END