/*_##################################### #######################################
_##
### Programming Windows Programming Design Guide-> Chapter 2 example Program
_ ## Author: xwlee
_ ## Time: 2007.06.01
### Chang'an University
_ ## Development condition: win2003 SERVER + vc6.0
_##
_ ## Program 2-1 scrnsize
_ ## Scrnsize. c file
### The scrnsize program shown in program 2-1 shows how to implement the messageboxprintf function,
_ ## This function has many parameters and can orchestrate their formats like printf.
_##
_##
_##
_ ## Scrnsize. c -- displays screen size in a message box
_ ## (C) Charles Petzold, 1998
_##
_####################################### ###################################*/
# Include <windows. h>
# Include <tchar. h>
# Include <stdio. h>
// This Is A Variable Parameter Function
Int cdecl messageboxprintf (tchar * szcaption, tchar * szformat ,...)
{
Tchar szbuffer [1024];
Va_list parglist;
// About va_list, va_start, and va_end, the macro used to define variable parameters
// The va_start macro (defined in stdarg. h) is usually equivalent:
// Parglist = (char *) & szformat + sizeof (szformat );
Va_start (parglist, szformat); // locate the address of the first Variable Parameter
// The last argument to wvsprintf points to the arguments
_ Vsntprintf (szbuffer, sizeof (szbuffer)/sizeof (tchar ),
Szformat, parglist );
// The va_end macro just zeroes out parglist for no good reason
Va_end (parglist );
Return MessageBox (null, szbuffer, szcaption, 0 );
}
Int winapi winmain (hinstance, hinstance hprevinstance,
Pstr szcmdline, int icmdshow)
{
Int cxscreen, cyscreen;
Cxscreen = getsystemmetrics (sm_cxscreen); // call the system function
Cyscreen = getsystemmetrics (sm_cyscreen); // call the system function
Messageboxprintf (text ("scrnsize "),
Text ("the screen is % I pixels wide by % I pixels High ."),
Cxscreen, cyscreen );
Messageboxprintf (text ("Chang 'an University, haha "),
Text ("the current screen size is: % I pixel width, % I pixel height. "),
Cxscreen, cyscreen );
Return 0;
}