GetDlgItem

fangchao918628 2008-10-21 04:13:57

PAINTSTRUCT ps;
HWND hwnd;
GetDlgItem(hwnd, IDC_View);//
HDC hdc = BeginPaint(hwnd,&ps);//
DrawIcon(hdc,5,5,g_icon);
EndPaint(hwnd,&ps);//

错误如下:
E:\vc程序\FilePro\new.cpp(86) : error C2664: 'void __thiscall CWnd::GetDlgItem(int,struct HWND__ ** ) const' : cannot convert parameter 1 from 'struct HWND__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\vc程序\FilePro\new.cpp(87) : error C2660: 'BeginPaint' : function does not take 2 parameters
E:\vc程序\FilePro\new.cpp(89) : error C2660: 'EndPaint' : function does not take 2 parameters
弄了很久不知道什么原因??
...全文
857 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wodemuqin 2008-11-13
  • 打赏
  • 举报
回复
CEdit *p = (CEdit*)GetDlgItem(ID_EDIT);
fangchao918628 2008-10-21
  • 打赏
  • 举报
回复
ok了!!
fangchao918628 2008-10-21
  • 打赏
  • 举报
回复
??msdn上这样
HWND GetDlgItem( 
HWND hDlg,
int nIDDlgItem
);

Parameters
hDlg
[in] Handle to the dialog box that contains the control.

nIDDlgItem
[in] Specifies the identifier of the control to be retrieved.
lenovo218 2008-10-21
  • 打赏
  • 举报
回复
EndPaint改成::EndPaint试试
Conry 2008-10-21
  • 打赏
  • 举报
回复
在MFC里面用SDK API要加上全局符号
PAINTSTRUCT ps;
HWND hwnd;
::GetDlgItem(hwnd, IDC_View);//
HDC hdc = ::BeginPaint(hwnd,&ps);//
::DrawIcon(hdc,5,5,g_icon);
::EndPaint(hwnd,&ps);//

lenovo218 2008-10-21
  • 打赏
  • 举报
回复
GetDlgItem,那两个参数弄反了吧?应该是GetDlgItem(IDC_View,hwnd);

15,979

社区成员

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

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