Un-Touchable Window

#include "hmg.ch"
PROCEDURE Main()
   nWindWidth := 500
   nWindHeight := 400
 
   nUnMWinCol := ( GetDesktopWidth() - nWindWidth ) / 2
   nUnMWinRow := ( GetDesktopHeight() - nWindHeight ) / 2
 
   DEFINE WINDOW frmUnTouchable ;
      AT 0,0 ;
      WIDTH nWindWidth ;
      HEIGHT nWindHeight ;
      TITle "UnTouchable Window" ;
      MAIN 
 
      ON KEY ESCAPE ACTION thisWindow.Release 
 
      DEFINE TIMER Timer_1 INTERVAL 1000 ACTION DontTouchMyWindow()
 
   END WINDOW
   frmUnTouchable.CENTER
   ACTIVATE WINDOW frmUnTouchable
RETURN // UTW.Main()
*.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
PROCEDURE DontTouchMyWindow()
   thisWindow.Row := nUnMWinRow 
   thisWindow.Col := nUnMWinCol 
   thisWindow.HEIGHT := nWindHeight
   thisWindow.WIDTH := nWindWidth
RETURN // DontTouchMyWindow()
*.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._

Working with IDE

Since HMG-IDE is an Integrated Development Environment, it’s possible building an entire project from scratch under HMG-IDE.

But this doesn’t mean “without coding”.

So, we can develop all GUI necessities of our project via HMG-IDE; but what, always we will need some little coding.

Then we can begin our project by building a project file. This is the very first and the easiest step:

Simply run IDE.exe and then select “New Project”.

When IDE ask, select (or build a new) a working folder and give a name (say Viva_HMG) to the project. .hbp extension will be assigned by IDE to project file.

Whenever IDE build a new project, automatically build and open a module file with name Main.prg and a form file with name Main.fmg.

Module file open by your text editor and form file open by IDE itself.

The content of your module file will be like this :

#include <hmg.ch>
Function Main
        Load Window Main
        Main.Center
        Main.Activate
Return

Basic rules :

– Every HMG project have one ( and only one ) “MAIN” procedure / function

– For using GUI controls, every HMG project have one ( and only one ) “MAIN” form.

So, names of both module and form files are “Main“.

File names doesn’t mandatory;

– only name of first procedure / function of first module file must be “Main” and

– “Window Type” property of one form must be “MAIN“.

You can see “module” tab of Project Browser window “(Main)” sign adjacent to the Main.prg and at the bottom line of “Properties” tab of Object Inspector “Window Type” property of “Main” form already set “MAIN” by IDE.

Now, we can work on our first form.

First we can give a name to it.

But what happening?

There isn’t “Name” in the properties list of our form !

Yes, this is correct; because:

– Basic rule 3: Every HMG form has their own name. Only exception is: a form to be LOAD, has a unchangeable name: TEMPLATE.

In other hand, you give an “alias” to a loaded form. The way of this is using “AS” close in the LOAD command. FE:

Load Window Main AS frmIDEBS_01

In this case you have change “Center” and “Activate” commands too :

frmIDEBS_01.Center
frmIDEBS_01.Activate

If you don’t use an “alias” in that way, you will use in all references of form by its file name; in this example : “Main”.

Now, its time to give a “Title” to the form.

For this, we will use “TITLE” property of form:

Double click “Title” and give a title in the open Input Box, say “It’s a Wonderful Life”

We can change easily background color of form:

Double click BackColor in the properties list.

Click “Custom“.

In the Color Select Form select your favorite background color or simply enter these tree values. : 64, 220, 210

Press RUN button and look to your application in work.

That’s all !  

Download source files

Browse by IDE

BROWSE is a control a few complicated than others. However HMG-IDE successfully support it.

In this sample we will build a Browse based application in a few steps using HMG-IDE.

Step – 1 : Make a folder for this sample.

Step – 2 : Copy TEST.DBF and TEST.DBT from \hmg\SAMPLES\TUTORIAL folder to your new folder.

Step – 3 : Run HMG-IDE and chose “New Project”.

IDE will ask you location and name for the new project; denote the folder you had build in the first step and give a name, say “IDEBrowse”.

IDE will build a new main module named “Main.Prg” and a new main form named “Main.fmg”

Step – 4 :

Double click “Main.prg” in the “Modules” tab of “Project Browser” window for editing this “main” module:

IDE send this module (.prg) file to your programing editor.

You will see your main program written by IDE :

#include <hmg.ch>

Function Main
 Load Window Main
 Main.Center
 Main.Activate
Return

Step – 5 :

Since BROWSE is a table based control, we must have a table and files opening/closing routines; these aren’t duties of IDE.

So add this two little procedures to the main.prg for opening and closing table:

Procedure OpenTables()
Use Test Shared
Return
Procedure CloseTables()
Use
Return


 Step – 6 :

Now, it’s time for making some arrangements on the form:

Title :

– Click  “Object Inspector [Main.Fmg]\Form\Properties\Title” :


– Give a “Title”, say “IDE Browse Sample” to form :


On Init Procedure :

– By clicking “Object Inspector [Main.Fmg]\Form\Events\OnInit” ;


– Assign OpenTables() procedure name to this event:

On Release Procedure :

– By clicking “Object Inspector [Main.Fmg]\Form\Events\OnRelease”;

– Assign CloseTables() procedure name to this event:

Step – 7 :

Now, we can place BROWSE control in our form:

– Click BROWSE button in the Toolbox:

– Then click anywhere in the form :

– Re-size control by dragging “resize” mark at the lower rigth corner :
 

 
 – If required, change placement of control by using “replace” mark ( at the upper-left corner )

 

– By using these two marks, you can place control in the form whatever you like:


 Step – 8 :

And now, we will make some arrangements on the BROWSE control :

After activating ( by clicking on it ) BROWSE control;

By selecting “Object Inspector[Main.Fmg]\Browse_1\Properties” give these properties to Browse_1 control:

– “Fields” property :

{‘Test->Code’,’Test->First’,’Test->Last’,’Test->Birth’,’Test->Married’,’Test->Bio’}

– “Headers” property :

{ ‘Code’, ‘First Name’, ‘Last Name’, ‘Birth Date’, ‘Married’, ‘Biography’ }

– “Widths” property :

{ 150, 150, 150, 150, 150, 150 }

– “Work Area” property :

Test

Note that “array” properties requires open and close curly-braces (‘{}’),  character properties doesn’t requires quotation marks (“”).

.
If you want allow editing  abilities to user, you have change default values (.F.) of these properties to .T.

 ALLOWEDIT
 ALLOWAPPEND
 ALLOWDELETE
 

Last Step :

That is All !

Click “Run” button ( or select “Run” from Project menu or simply press F5 key) for see results :


You have now a BROWSE based HMG application generated  by IDE.

When you use “Run” command or attempt to closing   your form by clicking “X” button, IDE ask you saving it ( if any change you have made ). You may also use Project\Save Form menu command.

Since IDE is a “Two-Way Form Designer”, you can edit .fmg files by double clicking its name in the “Forms” tab   of “Project Browser” window.

And since .fmg files are pure HMG source code, you can open a .fmg file by your editor to see  form source  code generated by IDE. Inspecting this code may be useful for better understanding and learning HMG.

You can also edit this file manually, but under your own risk ! Some modifications may not suitable to the standards of Form Designer.

Hex View

Hexadecimal file viewer.

This is a experimental project with first intend of point out the power of Harbour and HMG. So, HexView is considerably slow on large files, please be patient.

Download here ( source only ).