Pacific Database

Home | Contact | FAQs | View Cart

A world of information at your fingertips

Create & use a message box, with custom button text, custom icon, and user-defined position

You can give your application a touch of class by using the xMsgBox function to create a standard Windows message box with custom button text, a custom icon, and then display it at a custom position.

Important note: This function requires the SetFormIcon function.

 

Function signature

Public Function xMsgBox(sPrompt As String, _
                        sTitle As String, _
                        lFlagType As FlagType, _
                        lDefaultButton As DefaultButton, _
                        Optional lLeft As Variant = 0, _
                        Optional lTop As Variant = 0, _
                        Optional sText1 As Variant, _
                        Optional sText2 As Variant, _
                        Optional sText3 As Variant, _
                        Optional sIconPath As Variant, _
                        Optional hwndThreadOwner As Long = 0) _
                 As VbMsgBoxResult

Arguments

sPrompt String value specifying the message to be displayed.
 
sTitle String value specifying the text to be displayed in the message box's title bar.
 
lFlagType Enum value specifying the icon to be displayed in the text area. Can be any of the following values:

        mbNone = 0
        mbInformation = vbInformation
        mbExclamation = vbExclamation
        mbQuestion = vbQuestion
        mbCritical = vbCritical
 

lDefaultButton Enum value specifying the default button. Can be any of the following values:

        mbDefaultButton1 = vbDefaultButton1
        mbDefaultButton2 = vbDefaultButton2
        mbDefaultButton3 = vbDefaultButton3
 

lLeft Optional Variant number specifying the MsgBox's Left (X) display position (in pixels). This must be a valid numeric value. To use the default location, leave this argument blank.
 
lTop Optional Variant number specifying the MsgBox's Top (Y) display position (in pixels). This must be a valid numeric value. To use the default location, leave this argument blank.
 
sText1 Optional string value specifying the first button's Caption property.
Note: To specify only one button, leave sText2 and sText3 blank.
 
sText2 Optional string value specifying the first button's Caption property.
Note: To specify only one button, leave sText2 and sText3 blank.
 
sText3 Optional string value specifying the first button's Caption property.
Note: To specify only two buttons, leave this argument blank.
 
sIconPath Optional string value specifying the path and filename of the icon to be displayed in the MsgBox's title bar. Leave this argument blank unless you are specifying an icon file.
 
hwndThreadOwner The hWnd of the owning thread. Normally this can be Access.hWndAccessApp, but you can specify a form hWnd, or 0&.
 

Add the code to a standard module.