AppMessage (MsgNo As Long, MsgStr As String, MsgType As Long) As Long

Description

This event is fired when a normal message (not an error message) such as "No more forms available" is about to be displayed. (In the case of errors, the AppError event is fired if an error has occurred, and an error message is shown.)

With AppMessage you can show your own dialog, and return EV_OK_ABORT to tell FORMS not to display its usual message. Use the SetReturnValue method to tell FORMS how to continue.

The event handler should return EV_OK_ABORT if the message is not to be displayed and EV_OK otherwise. If the message contains multiple choices for the user (for example Yes/No, Yes/No/Cancel), use the SetReturnValue method on the Application object before returning from the event handler. The first parameter in SetReturnValue should always be 0, and the second parameter one of the following, depending on the user’s choice:

"O" (OK) 

 

"Y" (Yes)

 

"C" (Cancel)

Default value for Yes/No/Cancel and OK/Cancel messages.

"N" (No)

Default value for Yes/No messages.

Parameters

Parameter

Description

MsgNo 

Number identifying the message. If no message number exists, MsgNo is 0.

Msg

Contains the message as plain text.

MsgType 

Message type— a code that classifies the message:

MsgType

Description

Example

10500

Information message (OK)

"No more forms available"

10501

Warning message (OK/Cancel)

"All forms associated with <FormDefName> will be deleted"

10502

Yes/No message

"The current job description has been changed. Save?"

10503

Yes/No/Cancel

"The form definition has been changed. Save?"

Return values

Return value

Description

EV_OK

Normal return.

EV_OK_ABORT 

Tells FORMS not to display the message.

EV_ERROR

Has no effect.

Suggested usage

Could be used to turn off the FORMS’ messages to the user.

Example

This example shows a general outline of how to use the AppMessage event:

Function OnAppMessage(intMsgNo As Integer, strMsg As String, intMsgType As Integer) As Long

Dim strReturn As String

Dim strMyMsg As String

    'Map the message

    If intMsgNo = 0 Then

        strMyMsg = myMappingFunction(strMsg)

    Else

        strMyMsg = myMappingFunction(intMsgNo)

    End If

    'Get return value from user

    strReturn = myReturnFromUserFunction(strMyMsg)

    'Set the return value

    Call AppObj.SetReturnValue(0, strReturn)

    'Do not display the message in the application

    OnAppMessage = EV_OK_ABORT

End Function

Note: This code may not be suitable for use without additions based on your intended purpose.

Application-level events