szMessageBox

Description

szMessageBox formats a string and displays it using the MessageBox function in the Windows API.

C Prototype

int szMessageBox(
HWND hwnd, /* Input:  Parent window handle */
UINT style, /* Input:  Style of message box */
LPSTR szTitle, /* Input:  Title of message box */
LPSTR szFmt, /* Input:  Format string */
...); /* Input:  Arguments for format string */

Arguments

hwnd

The parent window handle to be passed to MessageBox. This should be the hwnd member of the lpServer structure passed to AutoTestFunc.

style

The style of the message box. For more information, see the fuStyle argument of the MessageBox function in the Windows API.

szTitle

The title of the message box. For more information, see the lpszTitle argument of the MessageBox function in the Windows API.

szFmt

A null-terminated format string compatible with the wsprintf function.

...

Arguments for the format string specified in the szFmt argument.

Return Value

szMessageBox returns the value returned by MessageBox.

Comments

Auto tests can call this function to display a message box. Because most auto tests are designed to be run without user interaction, this function should be called only when user interaction is required. To routinely log output, an auto test should call szLogPrintf.

Code Example

The following code example shows how AutoTestFunc might use szMessageBox to tell the user how to use a dialog box displayed by SQLDriverConnect:

#define CONN_STR_LEN 100
SQLCHAR InConnectString[CONN_STR_LEN], OutConnectString[CONN_STR_LEN];
SQLSMALLINT StringLength2;

/* szTestName is the test name returned by AutoTestName */
szMessageBox(lpServer->hwnd,
     MB_ICONINFORMATION | MB_OK,
     szTestName,
     "Click the Cancel button in the next 
               dialog box.");

lstrcpy(InConnectString, "DSN=");
lstrcat(InConnectString, lpServer->szValidServer0);
SQLDriverConnect(ConnectionHandle, lpServer->hwnd,
       InConnectString, lstrlen(InConnectString),
       OutConnectString, CONN_STR_LEN, 
                 &StringLength2,
       SQL_DRIVER_PROMPT);