Windows程序设计第五版——源代码002之SCRNSIZE.c
2016-08-16 13:42
363 查看
摘录于《Windows程序(第5版,珍藏版).CHarles.Petzold 著》P34
[cpp] view
plain copy
/*--------------------------------------------------------
SCRNSIZE.c -- Displays screen size in a message box
(c) Charles Petzold, 1998
--------------------------------------------------------*/
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
int CDECL MessageBoxPrintf(TCHAR * szCaption, TCHAR * szFormat, ...)
{
TCHAR szBuffer [1024];
va_list pArgList;
// The va_start macro (defined in STDARG.H) is usually equivalent to:
// pArgList = (char *) &szFormat + sizeof(szFormat);
va_start (pArgList, szFormat);
// 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, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
int cxScreen, cyScreen ;
cxScreen = GetSystemMetrics (SM_CXSCREEN) ;
cyScreen = GetSystemMetrics (SM_CYSCREEN) ;
MessageBoxPrintf (TEXT("ScrnSize"),
TEXT("The screen is %i pixels wide by %i pixels high."),
cxScreen, cyScreen);
return 0;
}
[cpp] view
plain copy
/*--------------------------------------------------------
SCRNSIZE.c -- Displays screen size in a message box
(c) Charles Petzold, 1998
--------------------------------------------------------*/
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
int CDECL MessageBoxPrintf(TCHAR * szCaption, TCHAR * szFormat, ...)
{
TCHAR szBuffer [1024];
va_list pArgList;
// The va_start macro (defined in STDARG.H) is usually equivalent to:
// pArgList = (char *) &szFormat + sizeof(szFormat);
va_start (pArgList, szFormat);
// 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, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
int cxScreen, cyScreen ;
cxScreen = GetSystemMetrics (SM_CXSCREEN) ;
cyScreen = GetSystemMetrics (SM_CYSCREEN) ;
MessageBoxPrintf (TEXT("ScrnSize"),
TEXT("The screen is %i pixels wide by %i pixels high."),
cxScreen, cyScreen);
return 0;
}
相关文章推荐
- Windows程序设计第五版章节记录
- windows程序设计第五版 第六章 KEYVIEW1.c
- Windows程序设计第五版读书笔记之一
- windows程序设计第五版 第四章SYSMETS3.C 示例分析(自己的笔记)
- Windows程序设计第五版
- Windows程序设计第五版——源代码001之HelloMsg.c
- Windows程序设计 (第五版) 中文版+英文原版下载
- Windows程序设计第五版——源代码002之SCRNSIZE.c
- windows程序设计-第五版--读书笔记(2)--宽字符集和Unicode--文中内容摘取
- Windows程序设计第五版——源代码003之HELLOWIN.c
- 摘自windows程序设计第五版
- 《Windows 程序设计(第五版,珍藏版)》第I部分 基础知识 学习总结
- 《Windows 程序设计(第五版,珍藏版)》第I部分 关于图的那些事儿 学习总结
- 关于WIN32窗体ID(Windows程序设计第五版)
- 关于WIN32窗体ID(Windows程序设计第五版)
- windows程序设计-第五版--读书笔记(1)---有些是书上文字拷贝
- Windows程序设计第五版(清华出版…
- C语言全局时钟(Windows程序设计 第五版 )
- Windows程序设计核心总结(打印机-2018.5.5)
- Windows程序设计之简单的动画效果(小球弹一弹)