Main Menu

HMG Tutor 2

Adding The Main Menu

We add a main menu to the program now:

#include "hmg.ch"
Function Main
DEFINE WINDOW Win_1 ;
   AT 0,0 ;
   WIDTH 400 ;
   HEIGHT 200 ;
   TITLE 'Tutor 02 - Main Menu Test' ;
   MAIN
   DEFINE MAIN MENU
      POPUP "First Popup"
         ITEM 'Change Window Title' ACTION  Win_1.Title := 'New Title'
         ITEM 'Retrieve Window Title' ACTION  MsgInfo ( Win_1.Title )
      END POPUP
   END MENU
END WINDOW
ACTIVATE WINDOW Win_1
Return

As you can see it is pretty easy and intuitive.

All the main menu stuff will be between DEFINE MAIN MENU / END MENU statements.
Each individual menu popup will be between POPUP / END POPUP statements.
Each individual menu item will be coded via the ITEM statement.

You can use as popups as you need and you can nest it without any limit.

By the way, another handy feature, a Message function used here :

The MsgInfo() Function

This is a very useful function. It will show a little message window (with the system information icon) and a message (character type) passed as parameter.

You can optionally add a title (passed as the second parameter).

Note: By nature, Message function uses options in local language. Here “Tamam” means “Ok” in my language ( Turkish).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.