各位帮帮新人那, 看了晕了一下午 就找不到原因!

xiangxuf 2008-11-27 03:27:23
void CMainFrame::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpdis)
{
BITMAP bm; //创建一个空的CBitmap 对
CBitmap bitmap;
bitmap.LoadOEMBitmap(OBM_CHECK); //将位图复制到Bitmap对象
bitmap.GetObject(sizeof(bm), &bm);

CDC dc; //把DRAWITEMSTRUCT结构中提供的设备描述句柄挂接到该对象上
dc.Attach(lpdis->hDC);

..
..

}
编译后产生错误如下:
ompiling...
MainFrm.cpp
F:\MFC Windows 程序设计\SelfCode\Colors\MainFrm.cpp(116) : error C2065: 'OBM_CHECK' : undeclared identifier
Error executing cl.exe.

Colors.exe - 1 error(s), 0 warning(s)

各位帮我看看是怎回事, 我也是才刚接触这玩意, 有点晕啊 , 谢谢各位!
...全文
229 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljsunlin 2010-04-23
  • 打赏
  • 举报
回复
楼上正解,谢谢
kgdusretg 2009-09-30
  • 打赏
  • 举报
回复
#define OEMRESOURCE // For OBM_CHECK

在staAfx.h 中加上这句!
rader2210 2008-11-28
  • 打赏
  • 举报
回复
把头文件加上就好了.在你这个类里,用到了其他类的函数,就把相应的类的头文件加上
wzaen 2008-11-28
  • 打赏
  • 举报
回复

BOOL CWnd::ShowWindow(int nCmdShow)
{
ASSERT(::IsWindow(m_hWnd));//这里没通过,检查一下,窗口是否正确创建,并成功。

if (m_pCtrlSite == NULL)
return ::ShowWindow(m_hWnd, nCmdShow);
else
return m_pCtrlSite->ShowWindow(nCmdShow);
}

xiangxuf 2008-11-28
  • 打赏
  • 举报
回复
改成了, 可以link通过了,

不过execute programm 时会弹出错误提示框 :
Microsoft Visual C++ Debug Library
program:f:\MFC Windows 程序设计\..\Debug\Colors.exeFile:winocc.cpp
line:301

for information on how your program can cause an assertion
failure,see the Visual c++ documentation on asserts.

(Press Retry to debug the application)

终止 重试 忽略


why ???????/
hacker1125 2008-11-28
  • 打赏
  • 举报
回复
在资源视图那看下是否有设置ID为OBM_CHECK的。而且要包含头文件。
jyh_baoding 2008-11-28
  • 打赏
  • 举报
回复
没有定义资源
xiangxuf 2008-11-27
  • 打赏
  • 举报
回复
还有为什么当我双击Colors.rc 时会跳转到ResourceView里面显示的是
一些Accelerator、Dialog、Icon、Menu...等的文件包 怎样才能显示出可以直接编辑源代码的编辑筐啊? 就是可以直接往里面编写代码的那个Colors.rc
呵呵不知道 说清楚了 没 ,各位老大应该能听明白吧
xiangxuf 2008-11-27
  • 打赏
  • 举报
回复
在stdafx.h的开头加上
#define OEMRESOURCE 后编译是通过了 ,但是link时又出现一下错误

--------------------Configuration: Colors - Win32 Debug--------------------
Linking...
ChildView.obj : error LNK2001: unresolved external symbol "protected: virtual long __thiscall CChildView::DefWindowProcA(unsigned int,unsigned int,long)" (?DefWindowProcA@CChildView@@MAEJIIJ@Z)
ChildView.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall CChildView::CalcWindowRect(struct tagRECT *,unsigned int)" (?CalcWindowRect@CChildView@@MAEXPAUtagRECT@@I@Z)
ChildView.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CChildView::Create(char const *,char const *,unsigned long,struct tagRECT const &,class CWnd *,unsigned int,struct CCreateContext *)" (?Create@CChildView@@UAEH
PBD0KABUtagRECT@@PAVCWnd@@IPAUCCreateContext@@@Z)
MainFrm.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CMainFrame::Create(char const *,char const *,unsigned long,struct tagRECT const &,class CWnd *,unsigned int,struct CCreateContext *)" (?Create@CMainFrame@@UAEHPB
D0KABUtagRECT@@PAVCWnd@@IPAUCCreateContext@@@Z)
Debug/Colors.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

Colors.exe - 5 error(s), 0 warning(s)
atiansk2006 2008-11-27
  • 打赏
  • 举报
回复
OBM_CHECK没有定义

#define OBM_CHECK 32760
bencharluo 2008-11-27
  • 打赏
  • 举报
回复
学习
debrogile 2008-11-27
  • 打赏
  • 举报
回复
#define OBM_CHECK 32760
pornographer 2008-11-27
  • 打赏
  • 举报
回复
吧bitmap从 资源里添加进去 取名叫 OBM_CHECK
roadblossom 2008-11-27
  • 打赏
  • 举报
回复
up
buyong 2008-11-27
  • 打赏
  • 举报
回复
在stdafx.h的开头加上
#define OEMRESOURCE
然后重新编译试试
weidong0210 2008-11-27
  • 打赏
  • 举报
回复
检测包含相关的头文件
xiangxuf 2008-11-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zqh886 的回复:]
OBM_CHECK没有定义
你是否加载了资源OBM_CHECK
[/Quote]

该怎样定义啊??
xiangxuf 2008-11-27
  • 打赏
  • 举报
回复
我是看了《MFC Windows 程序设计》这书上面第4章的一道例题 , 但我感觉还是蛮晕的,
zqh886 2008-11-27
  • 打赏
  • 举报
回复
OBM_CHECK没有定义
你是否加载了资源OBM_CHECK
xiny120 2008-11-27
  • 打赏
  • 举报
回复
Note that the constant OEMRESOURCE must be defined before including WINDOWS.H in order to use any of the OBM_ constants.

16,548

社区成员

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

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

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