Miscellaneous HMG samples

Miscellaneous Contributed samples and applications

Mini File Manager – Jayadev, Esgici, Dr. Soto

How I can build …

Building Harbour, HMG, Projects 

How I can build Harbour and / or HMG ?

How I can build a Harbour applications ?

How I can build a HMG applications ?

How I can build a console application via HMG ? 

How I can make an .exe ?

Grigory Filatov

Contributed works of Grigory Filatov

Adaptation FiveWin TsBrowse class
Color Table
Center Window’s Title
Closes application when no activity
Copy Protection (Get BIOS Name)

Get list of all controls

GIF animation demo

Is application running ?

In post-DOS Oss it’s possible running multiple applications, even multiple instance of same application simultaneously. Sometime running multiple instance of same application may cause unpredictable results. So requires impeding, For this purpose HMG offers SET MULTIPLE ON | OFF [WARNING] command which impedes (OFF) or allow (ON) attempts to run multiple instances of the application with optional warning for both situation.

Sometime may be requires decide to allowing at run time. In this case you need know either a running instance exist or not before allowing or impeding.

IsAppRunning() function is for help this situation.

#include <hmg.ch>


   LOCAL cCurrApp := HB_ProgName()
   IF IsAppRunning( cCurrApp )
      MsgSTop( cCurrApp + CRLF + CRLF +;
               "Application is running already !", "Error")
      DEFINE WINDOW frmIsAppRunTest ;
         ROW 0 ;
         COL 0 ;
         WIDTH 650 ;
         HEIGHT 450 ;
         TITLE "Testing 'IsAppRunning()' function" ;
         ON INIT MsgInfo( cCurrApp + CRLF + CRLF + ;
                          "Application is running for first time !",;
                          "No problem") ;
         ON KEY ESCAPE ACTION ThisWindow.Release
      END WINDOW // frmIsAppRunTest


RETURN // IsAppRunTest.Main()      


PROCEDURE IsAppRunning(;
                        cAppName )

   LOCAL aProcess := EnumProcessesID(),;      // --> return array { nProcessID1, nProcessID2, ... }      
         nInstance := 0,;
         lRVal := .F.
   FOR EACH n1ProcID IN aProcess 
      IF cAppName == GetProcessFullName( n1ProcID ) 
         IF ++nInstance > 1
            lRVal := .T.
   NEXT n1ProcID
RETURN lRVal // IsAppRunning()


What Is a Window ?

In computing, a window ( aka form ) is an enclosed, rectangular area on a display screen. Most modern operating systems and applications have graphical user interfaces ( GUIs ) that let divide display into several windows. Within each window, may run a different program or display different data.

Windows are particularly valuable in multitasking environments , which allow to execute several programs at once. By dividing display into windows, may seen the output from all the programs at the same time. To enter input into a program, you simply click on the desired window to make it the foreground process.


GUI enable to set the dimensions and position of each window by moving the mouse and clicking appropriate buttons. Windows can be arranged so that they do not overlap (tiled windows) or so they do overlap (overlaid windows). Overlaid windows (also called cascading windows) resemble a stack of pieces of paper lying on top of one another; only the topmost window is displayed in full. You can move a window to the top of the stack by positioning the pointer in the portion of the window that is visible and clicking the mouse buttons. This is known as popping. You can expand a window to fill the entire screen by selecting the window’s zoom box.

In addition to moving windows, changing their size, popping and zooming them, you can also replace an entire window with an icon (this is sometimes called minimizing). An icon is a small picture that represents the program running in the window. By converting a window into an icon, you can free up space on the display screen without erasing the window entirely. It is always possible to reconvert the icon into a window whenever you want.

How I can make an .exe ?

Making .exe (executable) means building application. So you may find answer of this question here.

Anyway I will work to re-describe the process by a simpler way:

Almost every HMG sample have two .bat file: build.bat and ide.bat and using these files are quite simple:

Open command / console window, go to directory ( by CD command) of the sample you want to compile, and enter a simple command :

build demo <- will build demo.exe from demo.prg
ide demo <- open HMG-IDE with demo.prg

( IDE will wait your “run” command by pressing “run” button.)

So you may use this two .bat files for your projects too.

Copy build.bat and / or ide.bat to your working <dir>, and modify them this way:

build.bat :

call c:\hmg\build.bat <myProject> | <myProgram>

ide.bat :

c:\hmg\ide\ide.exe <myProject> | <myProgram>

Note : in this syntax “|” means “or”; you don’t need enter both project and program file names nor this sign; simply enter either one or other.


– “c:\hmg\” depending on your environment (installation); such as c:\hmg.3.1.1\ or antything else;

– <myProject> | <myProgram> to your project / program file name.

Project file is a text file with “.hbp” extension and contains a list of name(s) of your program file(s).

After building such .hbp file, you may open it from directly HMG-IDE ( by “open project command) and again, you may build your .exe by  pressing “run” button.