Message Box with printf capability

This is a small utility funtion will simply put up a userdefined message box with a
string formatted like printf().

Example:


int MsgBox(UINT nType, PSTR sz,...)
{
    char ach[512];
    va_list args;
    va_start(args, sz);
    wvsprintf (ach, sz, args); /* Format the string */
    int retval = AfxMessageBox (ach, nType == 0 ? MB_OK|MB_ICONEXCLAMATION : nType);

    return retval;
}


void main(int argc, char *argv[])
{
  MsgBox(MB_OK|MB_ICONINFORMATION, "There are %ld commandline parameters - parameter one is %s", argc, argv[1]);
}

 

Last updated: 15 May 1998

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read