BeforeModalDialog event

Examples


The BeforeModalDialog event occurs when a modal dialog opens, but before it’s displayed.

Syntax

window_BeforeModalDialog(ByVal DlgType As Long, PromptString As String, Control1String As String, Control2String As String, Control3String As String, Answer As Long)

Parameters

window – A window object.

ByVal DlgType As Long – Returns the dialog type. The following constants specify the dialog type:

[spacer]

Constant

Description

dtModalAskDialog

An ask dialog. It contains one or more buttons, and displays message text.

dtModalGetStringDialog

A getstring dialog. It contains a data entry field and OK and Cancel buttons.


PromptString As String – The message’s text. Since multiple dialogs can appear for a single window, use the PromptString parameter to ascertain which modal dialog appeared. You can also change the PromptString text before Microsoft Dynamics GP displays the dialog.

Control1String As String...Control3String As String – Returns the corresponding button text in the modal dialog. You can also change the button’s text before Microsoft Dynamics GP displays the dialog. For getstring dialogs, use the Control3String to programmatically enter the text in the data entry field.

Answer As Long – A constant that specifies the buttons in the dialog:

[spacer]

Constant

Description

dcButton1

The first button in an ask dialog.

dcButton2

The second button in an ask dialog.

dcButton3

The third button in an ask dialog.

dcCancel

The Cancel button in a getstring dialog.

dcOK

The OK button in a getstring dialog.


Comments

Since the BeforeModalDialog event occurs before Microsoft Dynamics GP displays the modal dialog, you can change the contents of the modal dialog. To change the message text, set the PromptString parameter. To change the button text, set the Control1String, Control2String and Control3String parameters.

The AfterModalDialog event won’t occur for all dialogs displayed in Microsoft Dynamics GP. Dialogs that display a help button and whose title is “Microsoft Dynamics GP” will function like standard window objects in your project, and will not invoke modal dialog events when displayed.


Ask dialogs

The dtModalAskDialog constant of the DlgType parameter specifies an ask dialog. Ask dialogs display one or more buttons and message text. The following illustration shows an ask dialog and the corresponding parameters in the BeforeModalDialog event:

[spacer]

The Answer parameter of the BeforeModalDialog event lets you programmatically “click” a button, and dismiss the dialog automatically. To answer the ask dialog, set the Answer parameter to dcButton1 (clicks the first button), dcButton2 (the second button) or dcButton3 (the third button).

Getstring dialogs

The dtModalGetStringDialog constant of the DlgType parameter specifies a getstring dialog. Getstring dialogs typically contain a message, a data entry field, and OK and Cancel buttons:

[spacer]

The Answer parameter of the BeforeModalDialog event lets you programmatically “click” a button and dismiss the dialog automatically. To answer the getstring dialog, set the Answer parameter to dcCancel or dcOK. Prior to answering the dialog, you can also set the Control3String data entry field.


Documentation Feedback