ScrnSize.c
Upload User: guangxunco
Upload Date: 2007-07-26
Package Size: 2562k
Code Size: 1k
Category:

Windows Develop

Development Platform:

WINDOWS

  1. /*-----------------------------------------------------
  2.    SCRNSIZE.C -- Displays screen size in a message box
  3.                  (c) Charles Petzold, 1998
  4.   -----------------------------------------------------*/
  5. #include <windows.h>
  6. #include <tchar.h>     
  7. #include <stdio.h>     
  8. int CDECL MessageBoxPrintf (TCHAR * szCaption, TCHAR * szFormat, ...)
  9. {
  10.      TCHAR   szBuffer [1024] ;
  11.      va_list pArgList ;
  12.           // The va_start macro (defined in STDARG.H) is usually equivalent to:
  13.           // pArgList = (char *) &szFormat + sizeof (szFormat) ;
  14.      va_start (pArgList, szFormat) ;
  15.           // The last argument to wvsprintf points to the arguments
  16.      _vsntprintf (szBuffer, sizeof (szBuffer) / sizeof (TCHAR), 
  17.                   szFormat, pArgList) ;
  18.           // The va_end macro just zeroes out pArgList for no good reason
  19.      va_end (pArgList) ;
  20.      return MessageBox (NULL, szBuffer, szCaption, 0) ;
  21. }
  22. int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
  23.                     PSTR szCmdLine, int iCmdShow) 
  24. {
  25.      int cxScreen, cyScreen ;
  26.      cxScreen = GetSystemMetrics (SM_CXSCREEN) ;
  27.      cyScreen = GetSystemMetrics (SM_CYSCREEN) ;
  28.      MessageBoxPrintf (TEXT ("ScrnSize"), 
  29.                        TEXT ("The screen is %i pixels wide by %i pixels high."),
  30.                        cxScreen, cyScreen) ;
  31.      return 0 ;
  32. }