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:
a main program which will serve as the MDI container,
child programs (one program at the very least),
a start menu file used to call child programs.
Create a new project called My MDI Project
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)
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
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.
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.
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.
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
Project: mdi-2014
mdi_container_config4gl_startMenu_menuTypeMenu_tabNo
mdi_container_config4gl_startMenu_menuTypeMenu_tabYes
mdi_container_config4gl_startMenu_menuTypeTree_tabNo
mdi_container_config4gl_startMenu_menuTypeTree_tabYes