刀塔传奇 剑圣2觉任务:v c++中位图操作发生错误,求教高手

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 23:49:27
// 位图调用.cpp : Defines the entry point for the console application.
//

void CEx_BMPView::OnDraw(CDC*pDC)
{
CEx_BMPDoc*pDoc=GetDocument();
ASSERT_VALID(pDoc);
CBitmap m_bmp;
m_bmp.LoadBitmap(IDB_BITMAP1);
BITMAP bm;
m_bmp.GetObject(sizeof(BITMAP),&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
CBitmap*pOldmap=dcMem.SelectObject(&m_bmp);
pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&dcMem,0,0,SRCCOOPY);
dcMem.SelectObject(pOldbmp);
}
错误信息如下:
--------------------Configuration: 位图调用 - Win32 Debug--------------------
Compiling...
位图调用.cpp
d:\常用软件\visual studio\msdev98\myprojects\位图调用\位图调用.cpp(18) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

请教这里的高手,这如何解决?
加上#include "stdafx.h" 我也试过了,好象错误更多了。你把程序运行下就知道了

你这里面少了好多代码呢。其他的是没有还是省略了?

注释中 Defines the entry point for the console application. 是电脑生成的吗?
如果是,那你上来Project类型就选错了。你选的 控制台应用程序吧。

你要想用这段代码,就在新建工程时选 MFC AppWizard,工程名写成Ex_BMP。然后用这段代吗替换Ex_BMPView.cpp 中 OnDraw 函数。还得把 一个 BMP 图象 导进 资源文件中。ID为IDB_BITMAP1。这样就可以了。

补充一句:别告诉我你用的是VC++ Express,如果是,换版本吧。

加上#include "stdafx.h"