Class: ModalPanel

Properties  Events  Methods    Index of Classes

Creates modal popup panels

Hierarchy

cObject
---cUIObject
------DfBaseObject
---------DfBaseWindow
------------DfBaseUIWindow
---------------DfBaseContainer
------------------DfBaseDialog
---------------------DfBasePanel
------------------------DfBasetoolPanel
---------------------------FloatingPanel
------------------------------ModalPanel
---------------------------------AboutDialog
---------------------------------ReportPanel

Library: Windows Application Class Library

Package: Windows.pkg

Description

ModalPanel is used to create modal popup panels. By default, the modal panel will appear relative to the object that invoked it. It can be moved anywhere on the screen. While it is active, all other panels in the application are disabled. This class is used with non-data-aware child objects. If you need to use DEOs within your modal panel, you should use the dbModalPanel class.

Sample

Object MyPopupPanel is a ModalPanel
    Set Size to 100 150
    Set Label to "My Tool Panel"
    :
End_Object



Syntax

Use windows
 
Object object_name is a ModalPanel
    set size to height width
    set locate_mode to LocateMode
    set label to title
    :
End_Object



Note

Caption Bar Label

The text that will appear in a panel's caption bar is set with the Label property. Note that this label will not appear in the Windows task list.

Resizing a Panel

When an object of this class is resized by users, this object sends the onResize message to itself. This message is supplied with no definition as a "hook" procedure to use when some action, such as resizing child list objects, is desired on resizing of this object.

Locating a Panel

The location of a panel is controlled by the properties location and locate_mode. The default "smart" locate_mode will cause the panel to appear relative to the object that invoked it. This can be changed by changing the locate_mode property to no_locate and setting location as desired.

Exiting the Application

When a ModalPanel receives an exit_application message (e.g., the user presses the exit-application key), this message is converted into a close_panel message. This causes the panel and not the application to close. This behavior is consistent with all other Windows applications.

Invoking a ModalPanel

A ModalPanel object is activated by sending it the Popup_Modal message. This activates the object and starts a new level of user interface. When the panel is closed, the new level of user interface is ended and execution proceeds from the calling procedure. Often it is desirable to create a special interface to a modal panel which returns a status value to the calling procedure. In the following example, the ModalPanel's custom function LoginUser will pop up a password screen and return a 0 if the password failed and a 1 if it succeeded.

Object LoginPanel is a ModalPanel
    Set size to 100 100
    Set label to "Password"
    // custom property. The panel will set this true if the login is valid
    Property Integer LoginOk public False
    // objects and logic to enter and confirm password goes here
    :
 
    Function LoginUser returns integer
        integer PassWordOK
        Send Popup_Modal
        Get LoginOK to PassWordOK
        Function_Return PassWordOk
    End_Function
End_Object


This would be called with the following invoking procedure:

Procedure ..
    Integer PassWordOk
    Get LoginUser of (LoginPanel(self)) to PassWordOk
    If PassWordOk .
    Else .
End_Procedure



Message Boxes

Often modal popup objects are required to present simple confirmation messages (Save this record) or to present information (This is not a valid option). Although you could use a ModalPanel for this purpose, you will probably find it easier to use standard Windows message boxes to perform these tasks.

There are no new properties in this class. The following properties are set to give an object the proper modal appearance and behavior: Caption_bar is true, Border_Style is set to Border_Dialog, Minimize_Icon is false, Maximize_Icon is false, SysMenu_Icon is true, and Modal_State is true.