BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / soft-design / #32557同步于 2009/1/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
SoftDesign机器人发帖

求助MFC的问题

juffun
2009/1/21镜像同步6 回复
出错代码如下: void DrawPicToHDC(IplImage *img, UINT ID) { CDC *pDC=GetDlgItem(ID).GetDC(); HDC hDC=pDC->GetSafeHdc(); CRect rect; GetDlgItem(ID)->GetClientRect(&rect); SetRect(rect, 0,0,img->width,img->height); CvvImage cimg; cimg.CopyOf(img); cimg.DrawToHDC(hDC,&rect); ReleaseDC(pDC); } error C2660: 'GetDlgItem' : function does not take 1 parameters error C2228: left of '.GetDC' must have class/struct/union type error C2660: 'GetDlgItem' : function does not take 1 parameters error C2227: left of '->GetClientRect' must point to class/struct/union error C2660: 'ReleaseDC' : function does not take 1 parameters 不知道该怎么弄了,我对Hwnd Cwnd hdc cdc概念也相当不清楚,求大牛指教,如果需要的话我把整个代码打包发上来。谢谢了~~
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
wks机器人#1 · 2009/1/21
去msdn查吧。
wanlxp机器人#2 · 2009/1/23
GetDlgItem(ID).变为::GetDlgItem(ID)->试试
juffun机器人#3 · 2009/1/23
这两个有什么区别啊? 【 在 wanlxp 的大作中提到: 】 : GetDlgItem(ID).变为::GetDlgItem(ID)->试试
wanlxp机器人#4 · 2009/1/24
【 在 juffun 的大作中提到: 】 : 这两个有什么区别啊? 加了::之后被认为是windows API全局函数,没有加被认为是成员函数, 而使用全局函数的话是需要2个参数的,可以参见MSDN
wanlxp机器人#5 · 2009/1/24
【 在 juffun 的大作中提到: 】 : 出错代码如下: : void DrawPicToHDC(IplImage *img, UINT ID) { : CDC *pDC=GetDlgItem(ID).GetDC(); : ................... 改成这样就可以了 CDC *pDC=(CDC *)GetDlgItem(ID).GetDC(); HDC hDC=pDC->GetSafeHdc(); CRect rect; (CDC *)GetDlgItem(ID)->GetClientRect(&rect); SetRect(rect, 0,0,img->width,img->height); CvvImage cimg; cimg.CopyOf(img); cimg.DrawToHDC(hDC,&rect); ReleaseDC(pDC); 因为GetDlgItem返回是CWnd * 的指针
chidgine机器人#6 · 2009/2/19
好像不是那个问题吧。我觉得是它的函数实现没有写对。 void DrawPicToHDC(IplImage *img, UINT ID) { CDC *pDC=GetDlgItem(ID).GetDC(); 似乎应该改成 void (你所使用的类名称):: DrawPicToHDC(IplImage *img, UINT ID) { CDC *pDC=GetDlgItem(ID).GetDC();