/*===========================================================================
 *
 * GENWIN.CPP - 4 March 1999, Dave Humphrey
 *
 * Module containing general and useful methods for programming under
 * Windows.
 *
 *=========================================================================*/

	/* Required Includes */
#include "stdafx.h"
#include "genwin.h"


/*===========================================================================
 *
 * Function - int GenMsgBox (Type, pTitle, pString, ...);
 *
 * Displays the windows standard message box using the given values.  Accepts
 * format as per the printf() functions.  Maximum string length is around 1000
 * characters for the total message length.  Returns the value from the 
 * message box function.
 *
 *=========================================================================*/
int GenMsgBox (const UINT Type, const char *pTitle, const char *pString, ...) {
  CWnd *pWnd;				/* Temp window pointer */
  char buffer[MAX_GENMSG_LENGTH+1];	/* The temp output buffer */
  va_list args;				/* Variable argument list */

	/* Print the message string */
  va_start(args, pString);
  vsprintf (buffer, pString, args);
  va_end(args);

	/* Attempt to access the message box via the current main window */
  if ((pWnd = AfxGetMainWnd()) == NULL) return (AfxMessageBox(buffer, Type));
  return (pWnd->MessageBox(buffer, pTitle, Type));
 }
/*===========================================================================
 *		End of Function GenMsgBox()
 *=========================================================================*/