Simple Tutorial - 6 : More Choices

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Simple Tutorial - 6 : More Choices

Post by esgici »

Simple tutorial based upon HMG Offical Tutorial for beginners.

More Choices

There is various alternatives to get an user's choice besides RadioGroup.

One of them is the ListBox Control

Code: Select all

@ 10, 10 LISTBOX List_1 ITEMS {'Option 1','Option 2','Option 3'}
Using a Listbox, you can add, change or remove items at runtime.

Code: Select all

#include "minigui.ch"

Function Main

    DEFINE WINDOW Win_1 ;
        AT 0,0 ;
        WIDTH 400 ;
        HEIGHT 200 ;
        TITLE 'ListBox Test' ;
        MAIN

        DEFINE MAIN MENU
           POPUP "First Popup"
             ITEM 'Change ListBox Value'   ACTION  ;
                  Win_1.List_1.Value := 2
             ITEM 'Retrieve ListBox Value' ACTION  ;
                  MsgInfo ( Str(Win_1.List_1.Value))
             SEPARATOR
             ITEM 'Add List Item'       ACTION ;
                  Win_1.List_1.AddItem ('New List Item')
             ITEM 'Remove List Item'    ACTION ;
                  Win_1.List_1.DeleteItem (2)
             ITEM 'Change List Item'    ACTION ;
                  Win_1.List_1.Item (1) := 'New Item Text'
             ITEM 'Get List Item Count' ACTION ;
                  MsgInfo (Str(Win_1.List_1.ItemCount))
           END POPUP
        END MENU

        @ 10, 175 LISTBOX List_1 ITEMS {'Option 1','Option 2','Option 3'}

    END WINDOW

    CENTER   WINDOW Win_1
    ACTIVATE WINDOW Win_1

Return
Image



More Choices II

Another alternative to get an user's choice is the COMBOBOX.

Code: Select all

@ 10, 10 COMBOBOX Combo_1 ITEMS {'Option 1','Option 2','Option 3'}
Using a Combobox, is similar to ListBox.

Code: Select all

#include <minigui.ch>

Function Main

    DEFINE WINDOW Win_1 ;
        AT 0,0 ;
        WIDTH 400 ;
        HEIGHT 200 ;
        TITLE 'ComboBox Test' ;
        MAIN

        DEFINE MAIN MENU
           POPUP "First Popup"
             ITEM 'Change ComboBox Value'   ACTION  ;
                  Win_1.Combo_1.Value := 2
             ITEM 'Retrieve ComboBox Value' ACTION  ;
                  MsgInfo ( Str(Win_1.Combo_1.Value))
             SEPARATOR
             ITEM 'Add Combo Item'       ACTION ;
                  Win_1.Combo_1.AddItem ('New List Item')
             ITEM 'Remove Combo Item'    ACTION ;
                  Win_1.Combo_1.DeleteItem (2)
             ITEM 'Change Combo Item'    ACTION ;
                  Win_1.Combo_1.Item (1) := 'New Item Text'
             ITEM 'Get Combo Item Count' ACTION ;
                  MsgInfo (Str(Win_1.Combo_1.ItemCount))
           END POPUP
        END MENU

        @ 10, 10 COMBOBOX Combo_1 ITEMS {'Option 1','Option 2','Option 3'}

    END WINDOW

    CENTER   WINDOW Win_1   
    ACTIVATE WINDOW Win_1

Return
Image

Regards

esgici
Viva INTERNATIONAL HMG :D
Post Reply