Changing the Component Busy or Request Pending Messages

The Component Busy and Component Request Pending dialog boxes are provided by Visual Basic as simple default messages. There are many situations where these dialog boxes may not meet your needs.

In these situations, the Switch To button is inappropriate and may confuse the user of your program. You can specify a substitute message for either or both of the timeouts. Your messages will be displayed in a simple message box, without a Switch To button.

For the request pending condition, the message box has only an OK button. For the component busy condition, an OK button and a Cancel button are provided. If the user presses Cancel, error -2147418111 (&h80010001) will be raised in the procedure in which you made the request.

The following properties of the App object determine whether the Component Busy or Component Request Pending dialog box will be replaced by a message box and allow you to specify the text and caption of the message box.

OLEServerBusyMsgText Property

Specifies the message text to be displayed when the component busy condition occurs. Setting this property causes the alternate message box to be used in place of the usual Component Busy dialog box.

OLEServerBusyMsgTitle Property

Specifies the caption to be used if an alternate message is supplied for the component busy condition. (Only setting this property will not cause the alternate message box to be used.)

OLERequestPendingMsgText Property

Specifies the message text to be displayed when the request pending condition occurs. Setting this property causes the alternate message box to be used in place of the usual Component Request Pending dialog box.

OLERequestPendingMsgTitle Property

Specifies the caption to be used if an alternate message is supplied for the request pending condition. (Only setting this property will not cause the alternate message box to be used.)

The following example sets titles and message texts for both the component busy and pending request conditions, completely overriding the Component Busy and Component Request Pending dialog boxes.

Public Const APP_TITLE = "Demo Application"

Private Sub cmdLongTransaction_Click()
   On Error Goto LongTransaction_Error
   ' You may wish to set the titles once, in Sub Main.
   App.OLEServerBusyMsgTitle = APP_TITLE

   App.OLERequestPendingMsgTitle = APP_TITLE
   ' Message texts specific to this request.
   App.OLEServerBusyMsgText = "The component for _
      the " & "Long Transaction has not responded. _
      If " & "you have been waiting more than five " _
      & "minutes, you may wish to cancel this " _
      & "request and try it later." & vbCrLf _
      & "Call Network Services to verify that the " _
      & "component is running, or to report problems."
   App.OLERequestPendingMsgText = "Your request " _
      & "is still executing. " & vbCrLf _
      & "Call Network Services to verify that the " _
      & " component is running, or to report _
      problems."
   ' Code to make a request and use results...
   ' ...
LongTransaction_Cleanup:
   ' Code to perform any necessary cleanup...
   ' ...
   Exit Sub

LongTransaction_Error:
   If Err.Number = &h80010001 Then
      MsgBox "Transaction cancelled"
   Else
      ' Code to handle other errors.
   End If
   Resume LongTransaction_Cleanup
End Sub

Important   The length of your messages may be limited by the operating system. Messages more than a thousand characters in length can be used when the target operating system is Windows NT or Windows 95.