高手帮看错误在哪里?多谢多谢~~~

ugreat 2010-05-01 10:12:01
想把一副图像显示在一个picture控件里,在对话框中拉一个picture控件,定义其成员变量为,m_detect,然后获得其句柄。

HWND hWnd = m_detect.GetSafeHwnd();
HDC hdc=::GetDC(hWnd);

但是在这个地方总是显示错误,说error C2065: 'm_detect' : undeclared identifier。
这个m_detect应该是定义和初始化在testDlg.h和testDlg.cpp里,但是是在一个工程下的另外一个.cpp的函数里使用上述两句,会不会是这个地方有影响呢?附上此函数代码,向高手请教~~本人在做毕设,还是菜鸟级别~~

void CCaptureVideo::ImageProcessing(unsigned char*m_pDibBits, int m_height, int m_width)
{
HWND hWnd = m_detect.GetSafeHwnd();
HDC hdc=::GetDC(hWnd);

WidthA=640;
HeightA=480;

m_lpBmpInfoA=(LPBITMAPINFO)new char[WidthA*HeightA*3];
ZeroMemory(m_lpBmpInfoA,WidthA*HeightA*3);
m_lpBmpInfoA->bmiHeader.biSize=40;
m_lpBmpInfoA->bmiHeader.biPlanes=1;
m_lpBmpInfoA->bmiHeader.biBitCount=24;
m_lpBmpInfoA->bmiHeader.biWidth=WidthA;
m_lpBmpInfoA->bmiHeader.biHeight=HeightA;
m_lpBmpInfoA->bmiHeader.biSizeImage=WidthA*HeightA*3;
CRect rc0;//获取Static控件的大小范围
m_detect.GetClientRect(&rc0);
m_hDIB=DrawDibOpen();

if(m_hDIB!=NULL)
{
DrawDibBegin(m_hDIB,
hdc,
rc0.Width(), // don't stretch
rc0.Height(), // don't stretch
&m_lpBmpInfoA->bmiHeader,
WidthA, // width of image
HeightA, // height of image
0
);
DrawDibDraw(m_hDIB,
hdc,
rc0.left, // dest : left pos
rc0.top, // dest : top pos
rc0.Width(), // don't zoom x
rc0.Height(), // don't zoom y
&m_lpBmpInfoA->bmiHeader, // bmp header info
m_pDibBits, // bmp data
0, // src :left
0, // src :top
WidthA, // src : width
HeightA, // src : height
DDF_SAME_DRAW // use prev params....
);
}
delete[]m_lpBmpInfoA;m_lpBmpInfoA=NULL;



}
...全文
193 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
stjay 2010-05-01
  • 打赏
  • 举报
回复
类之间的调用,得看整个工程的设计,才好修改

CCaptureVideo?里面定义个CtestDlg testDlg;成员可以么?
然后testDlg.m_detect.xxx
向立天 2010-05-01
  • 打赏
  • 举报
回复
m_detect是你testDlg的成员变量
只能在testDlg类内使用
ugreat 2010-05-01
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dirdirdir3 的回复:]

在cpp的前面加上
#include "testDlg.h"
[/Quote]

试过了,可是错误会更多~~

error C2065: 'IDD_MYFIRSTDIRECTSHOW_DIALOG' : undeclared identifier
这个是对话框的名称。。之前的错误还是存在
dirdirdir3 2010-05-01
  • 打赏
  • 举报
回复
在cpp的前面加上
#include "testDlg.h"
尹成 2010-05-01
  • 打赏
  • 举报
回复
把m_detect放在testDlg类内,然后在头文件中加入#include "resource.h"
Fireway2008 2010-05-01
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ugreat 的回复:]
引用 1 楼 dirdirdir3 的回复:

在cpp的前面加上
#include "testDlg.h"


试过了,可是错误会更多~~

error C2065: 'IDD_MYFIRSTDIRECTSHOW_DIALOG' : undeclared identifier
这个是对话框的名称。。之前的错误还是存在
[/Quote]

在出错的'IDD_MYFIRSTDIRECTSHOW_DIALOG'对话框头文件内,加入一句:
#include "resource.h"
ugreat 2010-05-01
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 schlafenhamster 的回复:]

picture控件是CStatic,派生一个自己的,把绘图功能放paint中,绘那个图可以由view传给dlg再给pic
[/Quote]

呃你说得好简单,能不能给段代码什么的?多谢~~
schlafenhamster 2010-05-01
  • 打赏
  • 举报
回复
picture控件是CStatic,派生一个自己的,把绘图功能放paint中,绘那个图可以由view传给dlg再给pic
ugreat 2010-05-01
  • 打赏
  • 举报
回复
发个自定义消息给对话框让对话框自己处理
[/Quote]


具体怎么做?请教请教
向立天 2010-05-01
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ugreat 的回复:]
引用 3 楼 xianglitian 的回复:

m_detect是你testDlg的成员变量
只能在testDlg类内使用


那有没有解决办法啊,我把函数挪过去也不太好办,有没有比较简单的办法呢
[/Quote]

发个自定义消息给对话框让对话框自己处理
ugreat 2010-05-01
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 stjay 的回复:]

类之间的调用,得看整个工程的设计,才好修改

CCaptureVideo?里面定义个CtestDlg testDlg;成员可以么?
然后testDlg.m_detect.xxx
[/Quote]


这个也试过了,还是不行啊。。。
ugreat 2010-05-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 xianglitian 的回复:]

m_detect是你testDlg的成员变量
只能在testDlg类内使用
[/Quote]

那有没有解决办法啊,我把函数挪过去也不太好办,有没有比较简单的办法呢

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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