请问下面这段程序怎么编译?

icelover 2004-07-19 01:38:14
这是FENG YUAN 的Windows Graphics Programming Win32 GDI and DirectDraw书上第一章的一个例子
#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,LOGPIXELSX) / 72,
0,0,0,FW_BOLD,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);
}
编译的时候说unresolved external symbol _main referenced in function _mainCRTStartup
请问应该在Project settings里面做什么样的设置才能编译通过?
...全文
73 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
步履人生 2004-07-19
  • 打赏
  • 举报
回复
you must create a Main()function first, and put all of the codes into a .cpp file,

and then you can use c++ compiler to compile it.

use vc++ is ok for this.
yangang000 2004-07-19
  • 打赏
  • 举报
回复
这种垃圾书就不要看了
icelover 2004-07-19
  • 打赏
  • 举报
回复
你指的是subsystem:windows吧?
这个好像默认(建立一个空的win32 project)就是subsystem:windows啊
Kudeet 2004-07-19
  • 打赏
  • 举报
回复
把project->setting ->link 下面的文本框里的system:console改syetem:window,可能书写有误,大致意思差不多.

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧