Setting a Start Menu by Methods of ui.Interface Class

 

We want to run two programs in the MDI mode. These programs are “Hello” and “GoodBye”.

 

 

 

To run programs in the MDI mode you need to have the following:

 

  1. Create a new project called My MDI Project

 

  1. Create three new programs

 

my_mdi_program– this program will serve as the MDI container (it is called main program))

hello_program, goodbuy_program – these programs will be run in the MDI mode (they are called child programs)

 

  1. Create 4gl source files hello_source and goodbye_source to hold corresponding codes

 

hello_program hello_source:

 

MAIN

 

OPEN WINDOW Hello AT 5,20 WITH 5 ROWS, 25 COLUMNS

DISPLAY "Hello)" AT 2,2 ATTRIBUTE(GREEN, BOLD)

 

CALL fgl_getkey()

 

END MAIN

 

goodbye_program goodbye _source:

 

MAIN

 

OPEN WINDOW GoodBye AT 15,20 WITH 5 ROWS, 25 COLUMNS

DISPLAY " GoodBye(" AT 2,2 ATTRIBUTE(RED, BOLD)

 

CALL fgl_getkey()

 

END MAIN

 

  1. Build and deploy child programs. Child program must be compiled and deployed to the application server before you run the main program. Child programs do not get deployed automatically.

 

  1. Create 4gl source file main_source to hold the code:

 

my_mdi_program main _source:

 

MAIN

 

   CALL ui.Interface.setType("container")

   CALL ui.Application.GetCurrent().setMenuType("Menu")

   CALL ui.Interface.setName("My MDI Container")

   CALL ui.Interface.setText("Welcome to the MDI mode")

   CALL ui.Interface.loadStartMenu("startmenu")

 

 MENU

   COMMAND "Accept"

   EXIT MENU

 END MENU

 

END MAIN

 

      

Please, remember that the main program must include the methods setName(),setType(), and setStartMenu(). Other methods are optional.

 

  1. Use Window Builder to create the start menu file.

a. Create a new Window Builder form called my_mdi_program mdi_startmenu

b. Use MenuBar, MenuGroup, and MenuCommand widgets to create the start menu.

 

 

<?xml version="1.0" encoding="UTF-8"?>

<form xmlns="http://namespaces.querix.com/2011/fglForms" title="startmenu">

     <topmenu title="Menu bar" fieldType="FORM_ONLY" fieldTable="formonly" enable="true" visible="true" identifier="c1" type="menubar">

       <menuitems>

              <menugroup text="My MDI Project" fieldType="FORM_ONLY" fieldTable="formonly" enable="true" visible="true" identifier="mg1">

                     <menuitems>

                           <menucommand text="Hello" fieldType="FORM_ONLY" fieldTable="formonly" enable="true" visible="true" identifier="h">

                                  <oninvoke type="startprogrameventhandler" programName="hello_program" programPort="default-1889" programServer="10.38.57.180:9090" userId="system"/>

                           </menucommand>

                           <menucommand text="GoodBye" fieldType="FORM_ONLY" fieldTable="formonly" enable="true" visible="true" identifier="g">

                                  <oninvoke type="startprogrameventhandler" programName="goodbye_program" programPort="default-1889" programServer="10.38.57.180:9090" userId="system"/>

                           </menucommand>

                     </menuitems>

              </menugroup>

       </menuitems>

     </topmenu>

     <screenrecords>

       <screenrecord identifier="FormOnly"/>

     </screenrecords>

</form>

 

c. Set properties for menu commands as shown in the screenshots below.

 

 

 

  1. Build and run the main program.     If everything was done properly, you will be able to

a. see the MDI container

 

 

b. open the menu My MDI Project

 

 

c. run hello_program

 

 

d. run goodbye_program

 

 

 

Example programs:

Project: mdi-2014