我尝试使用API,
HWND GetDlgItem(
HWND hDlg, // handle of dialog box
int nIDDlgItem // identifier of control
);
但是编译时当成void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;
怎么在VC中使用这个API函数?用其他怎么获得HWND??
HWND GetDlgItem(
HWND hDlg, // handle of dialog box
int nIDDlgItem // identifier of control
);
但是编译时当成void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;
怎么在VC中使用这个API函数?用其他怎么获得HWND??
解决方案 »
- 如何用PC机的rs232串口控制伺服电机转动啊
- 菜鸟问题
- 急~~~关于OVERLAPPED的奇怪问题(IOCP)
- 如何把“深灰色泥质粉砂岩”这句话按“色、质、岩”这三个字断开?
- 无聊,大家来给俺估个价~~~,随便调侃。
- 如何编写实时监控的程序?
- 请教在编写运行其他程序的代码时怎么设置路径?
- error C2664: 'int __thiscall CListCtrl::InsertItem(int,const char *)' : cannot c
- 我怎样知道程序已经运行??
- Access violation???
- 急救!!求在mfc里面画圆画弧的程序
- 为什么我在FormView里画的图拖动窗口图形就没有了?????
如果要用你说的那个形式
可以GetDlgItem( int nID, this_>GetSafeHandle() ) ;
即可
CWnd::GetDlgItem已经将API ::GetDlgItem包装起来了
在VC里用void CWnd::GetDlgItem( int nID) const;即可比如对话框上有个控件IDC_EDIT
这样用
CEdit* m_pEdit;
m_pEdit=GetDlgItem(IDC_EDIT);
这样就取得了控件的指针
即可
方法一:
您没有为edit关联相关变量,则:
void CTempDlg::OnButtonSet()
{
// TODO: Add your control notification handler code here
CEdit* pEdit=(CEdit *)GetDlgItem(IDC_EDIT1);
pEdit->SetWindowText("你好");
}
方法二:
您为edit关联了相关的变量CEdit m_edit;
则:
void CTempDlg::OnButtonSet()
{
// TODO: Add your control notification handler code here
m_edit.SetWindowText("sads");
}
另外,您说的出现的错误可能是api中的好象加上;;吧!!!
HWND GetDlgItem(
HWND hDlg, // 窗口句柄
int nIDDlgItem // 控件 ID
);
在 MFC 里用时别忘了前面加上 :: 符号
用这个函数就这样调
C***Dlg dlg;
dlg.GetDlgItem(ID_***);::GetDlgItem(CWnd* phwnd, int ID);
用这个函数就这样调
C***Dlg dlg;
::GetDlgItem(dlg, ID_***);