An explanation about HMG …

An explanation about Harbour, HMG and HMG-IDE

By Sri  Rathinagiri » Mon Sep 08, 2014 12:44 pm

Clipper programmers sometimes find it difficult to accommodate with HMG. The reason is the difference between TUI (Text User Interface) and GUI. In GUI, the program control is in the hands of the user and it is event driven. User can click on anything (say minimize button, maximize button, even another program running behind or any controls). So, it is our duty to design the whole window and wait for user’s action and write procedures for each and every action of the user.

GUI offers many innovative controls like Grid, Combobox, Button, Spinner etc., as against only textbox in TUI. So, we have to eventually accommodate events for all these controls.

Now, coming to HMG as not only a GUI library but a bundle of all. Even though HMG is directly based on the latest Harbour versions, HMG comes as a bundle. You need not install any other software to build a windows application. Full stop. 🙂 It contains the GUI library, PRG compiler, C Compiler and all the supporting software products to successfully build an application.

People (at least me) sometimes misunderstand GUI and OOP as one and the same. GUI and OOP are different and independent to each other. GUI can be made to work with or without OOP and vice versa. HMG is based on Win32 API system. Win32 API system works on handles and hooks. Every window/control in HMG is provided with a handle (like the file handle in clipper) and events are hooked on that particular handle. Once any hooked event is fired by the user (say a click of a button) immediately Win32 API searches for a CallBack function which is provided by the developer via HMG. The beauty of HMG would be, the developer is made free from handling all these internal affairs, handles, hooks and callback procedures. Instead he can concentrate on what is to be done if the event is fired.

You will be astonished to see how a ‘define window’ statement in HMG invokes 100s of lines of Harbour and C code. Please see the source folder of HMG if you want to know in detail.

Again, the advantage of HMG is, you need not include any dlls with your executable code as it is based on Win32 API. The application would run in XP to Windows version 8 (even in Windows 97 some cases).

Now coming to your questions.

1) How to get a lot of of source codes containing of samples to handle screen-menus ; from basic up to complex/advanced screen-menus?

To answer this questions, pls help us by showing links which permit us to download. And by sharing your source-code available for public.

Screenshoot attached herein, is a sample screen handle we need to implement on our application, ASAP. Being programmers for long time, we need any advanced skill in order to satisfy our users/clients currently still using our DOS-apps-versions.

You can start with Your HMG Directory\SAMPLES\Basics\TUTORIAL folder. It contains various tutorials for basic programmers. Then you can see basic and controls sub-folders of samples. I don’t think that any advanced skill set is required to satisfy our existing DOS clients. Actually ther will be happy to update their programs to Windows version as it is user friendly and more flexible.

2) How to avoid one app/EXE is double-run by users in the same computer?

This problem never arise under DOS who own a single window. I noticed when exercising HMG-ID (executing IDE.EXE) to build project, the RUN (F5) function fails to detect the problem. that’s way HMG-IDE made run-time error as if the mistake came from source program.

Yes, it is a valid point. In HMG-IDE previous version there was an error marking ‘Is the program still running?’. I don’t know what happened to that in the recent versions. I will request Claudio to look into this. Thanks for reporting.

3) Why stable version release from official Harbour-Project differ from this forum?

The project says the latest stable version is 3.0.0. while this forum says HMG 3.3.1. Any clarification in this matter is urgently needed to avoid confusion.

Because they are entirely different projects. As I have discussed earlier, HMG is based on Harbour. But it is a bundle by itself. Some major implementations have been made after the versions HMG 3.0. Introducing Unicode in 3.1. Made it to a stable version in 3.2. And the latest and significant achievement is HMG in 64 Bits, which made it to 3.3 series.

HMG Extended is also developed and released parallelly and they have their own version numbering system.

IMHO, we can use the latest stable versions for the development.

4) Pls help us describe what the differences between this 3 services you’ve been provided: Harbour Compiler, Harbour Mini GIU, Harbour-IDE. We need to know exactly when and why use them?

Harbour compiler is the core. Habour MiniGUI is the Win32 wrapper library to access the GUI aspects of the programs. HMG IDE is a tool to develop and build our software in Harbour MiniGUI.

You can use simply Harbour if you need only console mode. If you want GUI support, you can use Harbour MiniGUI and its build.bat ( even without using HMG IDE at all).

If you need Forms Designer and an easy build system, you can use HMG IDE which can co-ordinate your forms, database, resources (icons, pictures etc) and linking other third party libraries.

Sri Rathinagiri
Sivakasi, India

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Courtesy of author, this article borrowed from here.

HMG Samples

About HMG Samples

Language Related

 Arrays

Array Arithmetic

Load / Save ANY array

Conversion

DOS -> Windows Character Conversion

National Issues

National Alternate Collating Sequence

National Change Case

 Windows

Tracking Mouse

Controls

Browse

Quick Search    

Combo box

Dynamic ComboBox

Edit Box

Word wrap in EditBox

 Grid

Get Data Into Grid via IDE

Text Box

Auto fill in text box

Search in and Fill Box (SFilBox) 

Tree

Tree Menu

Two Methods for Tree

Functions

 Drives, Directories and Files

Drives and Directories

Directory List

Fill Directory List

PutFile() with default file name

Messages

HMG Message Functions

Message for multiple values

Message Extended

Where Is It ?

Improvements in Message functions

Miscellaneous

Is application running ?

Get Process ID

Simple Error Handling

Funny

Cuckoo Clock

Untouchable window

Warn Lazy User

Pegs Game

Drawing

Play Draw

Draw Border

Printing

 Text Mode

Using printer under Windows 

Obsolete ways

Send to File

Print File

GUI Mode

HMG Print

 HMG Print ( Mini Print ) for beginners in 10 easy steps

Print a plain text file by HMG Print – 1

HMG Report

HMG HPDF

HMG_HPDF — Bill

Unicode

HMG Unicode

Utilities

Color Codes

DB Validate 

Hex View

Mini Agenda

DBA : Data Base Assistant

Low-Level DBU

x-Base Modul List

Mini Search Machine (2014) 

Data entry boxes

HMG Tutor 21 — Data-Controls II:

TEXTBOX, DATEPICKER, CHECKBOX, EDITBOX

The ‘data-version’ of these controls required the use of the following properties / methods to bound them to a database field:

Field Property: Stablishes the field that control is bounded to.
Refresh Method: Updates control content based on current field content.
Save method: Updates database file according control content.

#include "hmg.ch"

Function Main
DEFINE WINDOW Win_1 ;
   AT 0,0 ;
   WIDTH 640 ;
   HEIGHT 480 ;
   TITLE 'Tutor 21: Data-Bound Controls Test' ;
   MAIN ;
   ON INIT OpenTables() ;
   ON RELEASE CloseTables()

   DEFINE TOOLBAR ToolBar_1 BUTTONSIZE 100,30 FLAT RIGHTTEXT BORDER

      BUTTON TOP ;
         CAPTION '&Top' ;
         PICTURE 'primero.bmp' ;
         ACTION ( DbGoTop() , Refresh() )

      BUTTON PREVIOUS ;
         CAPTION '&Previous';
         PICTURE 'anterior.bmp' ;
         ACTION ( DbSkip(-1) , Refresh() )

      BUTTON NEXT ;
         CAPTION '&Next';
         PICTURE 'siguiente.bmp' ;
         ACTION ( DbSkip(1) , if ( eof() , DbGoBottom() , Nil ) , Refresh() )

      BUTTON BOTTOM ;
         CAPTION '&Bottom' ;
         PICTURE 'ultimo.bmp' ;
         ACTION ( DbGoBottom() , Refresh() )

      BUTTON SAVE ;
         CAPTION '&Save' ;
         PICTURE 'guardar.bmp' ;
         ACTION ( Save() , Refresh() )

      BUTTON UNDO ;
         CAPTION '&Undo' ;
         PICTURE 'deshacer.bmp' ;
         ACTION ( Refresh() )

   END TOOLBAR

   @  50,10 LABEL LABEL_1 VALUE 'Code:'
   @  80,10 LABEL LABEL_2 VALUE 'First Name'
   @ 110,10 LABEL LABEL_3 VALUE 'Last Name'
   @ 140,10 LABEL LABEL_4 VALUE 'Birth Date:'
   @ 170,10 LABEL LABEL_5 VALUE 'Married:'
   @ 200,10 LABEL LABEL_6 VALUE 'Bio:'

   @ 50,200 TEXTBOX TEXT_1;
            FIELD TEST->CODE ;
            NUMERIC ;
            MAXLENGTH 10

   @ 80,200 TEXTBOX TEXT_2;
            FIELD TEST->FIRST ;
            MAXLENGTH 30

   @ 110,200 TEXTBOX TEXT_3;
             FIELD TEST->LAST ;
             MAXLENGTH 30

   @ 140,200 DATEPICKER DATE_4 ;
             FIELD Test->Birth

   @ 170,200 CHECKBOX CHECK_5 ;
             CAPTION '' ;
             FIELD Test->Married

   @ 200,200 EDITBOX EDIT_6 ;
             FIELD Test->Bio ;
             HEIGHT 100

END WINDOW

Win_1.Text_1.SetFocus

ACTIVATE WINDOW Win_1

Return Nil

Procedure Refresh
   Win_1.Text_1.Refresh
   Win_1.Text_2.Refresh
   Win_1.Text_3.Refresh
   Win_1.Date_4.Refresh
   Win_1.Check_5.Refresh
   Win_1.Edit_6.Refresh
   Win_1.Text_1.SetFocus
Return

Procedure Save
   Win_1.Text_1.Save
   Win_1.Text_2.Save
   Win_1.Text_3.Save
   Win_1.Date_4.Save
   Win_1.Check_5.Save
   Win_1.Edit_6.Save
Return

Procedure OpenTables
   USE TEST
Return
Procedure CloseTables
   USE
Return

TextBox Control

HMG Tutor 4

Getting data from the user (TextBox Control)

The TextBox control is the main way to obtain data from the user.

@ 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 ;
  AT 0,0 ;
  WIDTH 400 ;
  HEIGHT 300 ;
  TITLE 'Tutor 04 TextBox Test' ;
  MAIN
  DEFINE MAIN MENU
    POPUP "First Popup"
       ITEM 'Change TextBox Content' ACTION  ;
             Win_1.Text_1.Value := 'New TextBox Value'
       ITEM 'Retrieve TextBox Content' ACTION  ;
             MsgInfo ( Win_1.Text_1.Value)
       SEPARATOR
       ITEM 'Change Numeric TextBox Content' ACTION  ;
             Win_1.Text_2.Value := 100
       ITEM 'Retrieve Numeric TextBox Content' ACTION ; 
             MsgInfo ( Str(Win_1.Text_2.Value))
       SEPARATOR
       ITEM 'Change Numeric (InputMask) TextBox Content' ACTION ;
             Win_1.Text_3.Value := 1234.12
       ITEM 'Retrieve Numeric (InputMask) TextBox Content' ACTION ;
             MsgInfo ( Str(Win_1.Text_3.Value))
    END POPUP
  END MENU
  @  40 , 120 TEXTBOX Text_1
  @  80 , 120 TEXTBOX Text_2 NUMERIC
  @ 120 , 120 TEXTBOX Text_3 NUMERIC INPUTMASK '9999.99'
END WINDOW
ACTIVATE WINDOW Win_1
Return