编译程序解决方案
编译程序
下面是<<Windows图形编程>>一书的例 1.1.2:
//Hello2.cpp
#define STRICT
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#include <assert.h>
void CenterText(HDC hDC,int x,int y,LPCTSTR szFace,LPCTSTR szMessage,int point)
{
HFONT hFont=CreateFont(-point*GetDeviceCaps(hDC,LOGPIXELXY)/72,
0,0,0,FW_BOLD,TRUE,TRUE,FALSE,FALSE,
ANSI_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,VARIABLE_PITCH,szFace);
assert(hFont);
HGDIOBJ hOld=SelectObject(hDC,hFont);
SetTextAlign(hDC,TA_CENTER|TA_BASELINE);
SetBkMode(hDC,TRANSPARENT);
SetTextColor(hDC,RGB(0,0,0xFF));
TextOut(hDC,x,y,szMessage,_tcslen(szMessage));
SelectObject(hDC,hOld);
DeleteObject(hFont);
}
const TCHAR szMessage[]=_T("Hello,World");
const TCHAR szFace[]=_T("Times New Roman");
#pragma comment(linker,"-merge:.rdata=.text");
#pragma comment(linker,"_align:512");
extern "C" void WinMainCRTStartup()
{
HDC hDC=GetDC(NULL);
assert(hDC);
CenterText(hDC,GetSystemMetrics(SM_CXSCREEN)/2,GetSystemMetrics(SM_CYSCREEN)/2,
szFace,szMessage,72);
ReleaseDC(NULL,hDC);
ExitProcess(0);
}
请问在VC++命令提示符中如何编译它?谢谢了。
------解决方案--------------------
NewProject then copy
------解决方案--------------------
买本VC入门的书看一下。
下面是<<Windows图形编程>>一书的例 1.1.2:
//Hello2.cpp
#define STRICT
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#include <assert.h>
void CenterText(HDC hDC,int x,int y,LPCTSTR szFace,LPCTSTR szMessage,int point)
{
HFONT hFont=CreateFont(-point*GetDeviceCaps(hDC,LOGPIXELXY)/72,
0,0,0,FW_BOLD,TRUE,TRUE,FALSE,FALSE,
ANSI_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,VARIABLE_PITCH,szFace);
assert(hFont);
HGDIOBJ hOld=SelectObject(hDC,hFont);
SetTextAlign(hDC,TA_CENTER|TA_BASELINE);
SetBkMode(hDC,TRANSPARENT);
SetTextColor(hDC,RGB(0,0,0xFF));
TextOut(hDC,x,y,szMessage,_tcslen(szMessage));
SelectObject(hDC,hOld);
DeleteObject(hFont);
}
const TCHAR szMessage[]=_T("Hello,World");
const TCHAR szFace[]=_T("Times New Roman");
#pragma comment(linker,"-merge:.rdata=.text");
#pragma comment(linker,"_align:512");
extern "C" void WinMainCRTStartup()
{
HDC hDC=GetDC(NULL);
assert(hDC);
CenterText(hDC,GetSystemMetrics(SM_CXSCREEN)/2,GetSystemMetrics(SM_CYSCREEN)/2,
szFace,szMessage,72);
ReleaseDC(NULL,hDC);
ExitProcess(0);
}
请问在VC++命令提示符中如何编译它?谢谢了。
------解决方案--------------------
NewProject then copy
------解决方案--------------------
买本VC入门的书看一下。