Consultor Eletrônico



Kbase 20981: How to Use the Win32 API Function, MessageBoxA
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Unverified

GOAL:

How to Use the Win32 API Function, MessageBoxA

GOAL:

How to customize the Progress ALERT-BOX

FACT(s) (Environment):

Progress 4GL
Progress 8.2x
Progress 8.3x
Progress 9.x
Windows 32-bits

CAUSE:

The Win32 API Function, MessageBoxA, is called by the Progress 4GL whenever the MESSAGE statement is invoked with the VIEW-AS ALERT-BOX option.
The 4GL 'VIEW-AS ALERT-BOX' option provides the following configuration of buttons:

· YES-NO
· YES-NO-CANCEL
· OK
· OK-CANCEL
· RETRY-CANCEL

The Syntax for this, and it's usage are contained in the Progress 4GL
Language Reference, The Progress Programming Handbook and the Progress
On-Line Help.

Applications may may require some additional button configurations and, in the 4GL, the only solution is to create your own Dialog-Box and customize it to your requirements.

The Win32 API function that Progress uses 'under the sheets' is called MessageBoxA. This function offers a few more options than are offered through the 4GL 'VIEW-AS ALERT-BOX' option, and may possibly save a developer the time and effort of writing their own custom dialog.

The mode numbers, used to define the desired button configuration, are outlined in Progress Solution # 20983.

Below is the Procedure definition of this function as it is defined in a 4GL procedure.

To call this function from the 4GL, simply define the procedure as below, define an integer variable to handle the output parameter and execute it as follows:
RUN MessageBoxA ( INPUT CURRENT-WINDOW:HWND,
INPUT 'Place message text here',
INPUT 'Place Title text here',
INPUT <enter number representing mode here>,
OUTPUT iReturn ).

PROCEDURE MessageBoxA EXTERNAL "user32.dll" :
DEFINE INPUT PARAMETER piHWND AS LONG.
DEFINE INPUT PARAMETER pcText AS CHARACTER.
DEFINE INPUT PARAMETER pcCaption AS CHARACTER.
DEFINE INPUT PARAMETER piType AS LONG.
DEFINE RETURN PARAMETER result AS LONG.
END PROCEDURE.

The iReturn output parameter, referenced above, holds the return value which indicates which button was pressed by the user. You could use this so that your application can act according to the user's choice.