Popup_Modal - AppDialog

Allows invoking a view as a modal view

Type: Procedure

Return Data Type: Integer

Parameters: None

Return Value


Syntax
Procedure Popup_Modal Returns Integer

Call: Get msg_Popup_Modal to IntegerVariable


Description

The Popup_Modal message allows you to invoke a normally modeless View or dbView as a modal view.

When modal, the view will act as a ModalPanel, meaning that it will float outside of the application panel and all windows under it will be disabled. This means global menus and toolbars are disabled.

For example a customer view could be displayed as a modal dialog from within the order view as follows:

Procedure Prompt
        Send Popup_Modal to oCustomerView
        // because this is a modal dialog the code here will not be executed until after the
        // the view is closed. You can do post-popup processing here.
End_Procedure

The framework has no recommended way of working with modal views. The use of a view for two purposes, MDI-view and modal dialog, is not supported as a high level application technique. We are not recommending that this become a commonly used technique but it has been requested and, in the right conditions, could be useful. Note that this technique does have limitations, as the global menu and toolbars cannot be accessed by the modal view. In addition, using the same dialog for modal and modeless purpose can lead to confusion. An application should avoid the use of modal dialogs whenever possible.

A View or dbView can only be displayed once as a normal modeless view or a modal dialog. Therefore, if the view is already displayed as an MDI view, sending Popup_Modal will do nothing. You could test for this and handle this condition yourself.

Procedure Prompt
    Boolean bActive
    Get Active_State of  oCustomerView to bActive
    If (bActive) Begin
        Send Close_Panel of oCustomerView
    End
    Send Popup_Modal of oCustomerView
End_Procedure

If you are invoking a view as modal dialog, that view must first be created. Therefore, this technique may not work if your views are deferred (see Deferred_State), as they may not be created yet. There is a technique which can be used to make sure that a view is created. Views that are created using the Active_View or Deferred_View syntax (which is the normal syntax used to create views) always create a method that is used to activate the view and to create it if needed. This usually takes the format of:

Send Activate_ + view name    (e.g., Send Activate_oCustomerView)

In addition, an additional method is created that creates the view, if needed, but does not activate it. This takes the format of:

Send  Activate_  + view name + _Handle   (e.g., Send Activate_oCustomerView_Handle).

This could be used to make sure that the view is created and to create it as needed.

Procedure Prompt
    Handle hoView
    // make sure view is created if deferred. 
    Get Activate_oCustomerView_Handle to hoView
    Send Popup_Modal of oCustomerView
End_Procedure

This Popup_Modal technique will work with standard views. Do not use this in conjunction with the Modal_State property (don't set this and don't augment it). Modal_State should never be set in a windows application.