Hello World - 2
In the our first example in Quick Start post, we wrote the "Hello World" clause on the title bar. Now, let's put it on the form.
Build a new project with "HelloWorld2" name, copy HelloWord.prg to HelloWorld2.prg and change it as below:
#include <minigui.ch>
Code: Select all
Function Main
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 200 ;
TITLE 'Hello World-2' ;
MAIN
DEFINE LABEL lblHello
ROW 75
COL 125
VALUE "Hello World !"
FONTNAME "Lucida"
FONTSIZE 16
END LABEL
END WINDOW
ACTIVATE WINDOW Win_1
Return
DEFINE LABEL and END LABEL statements are for "Label" definiton structure for the a window ( in this example Windows named as "Win_1" ). Label itself must have a name ("lblHello" in this example), and this name must be unique, such as a variable name. Beginning these names with a descriptive prefix ( "lbl" in the example) is a good programming practice.
Between DEFINE - END statements there are main properties of this label. Row, col numbers ( in pixels of course), value (for labels, value is a string constant to write in the your form/window) and font properties (NAME and SIZE)
Almost every GUI control definitions HMG have two syntax : With DEFINE and END structure and with @ command. Thus in the above example instead of DEFINE LABEL and END LABEL structure, you can use alternate @ syntax :
Code: Select all
@ 75, 125 LABEL lblHello ;
VALUE "Hello World !" ;
FONT "Lucida" ;
SIZE 16
A last note for this example : place
CENTER WINDOW Win_1
statement blove END WINDOW stament and notice that how much HMG is powerful.
Hello Word - 3
Don't worry ! This is the last; and important.
Extract DEFINE LABEL - END LABEL structure or @ ...,... LABEL command ( which one is currently exist) and then instead of them place this line :
MsgBox( "Hello World !" )
There are a lot of message functions, with name prefixed by "Msg":
Code: Select all
MsgExclamation()
MsgInfo()
MsgStop()
MsgOkCancel()
MsgRetryCancel()
MsgYesNo()
The first three message funcitons returns NIL, and the last three returns a logical value.
Try and observe results.
After building and running, try a more important feature: reduce your program to these minimum size:
Code: Select all
#include <minigui.ch>
Function Main
MsgBox( "Hello World !" )
Return
Regards
esgici