[英]How to get C++ MFC Control HANDLE by it's id?
I have for example IDC_EDIT1 C++ MFC Controls , How Can I get its handle ?例如,我有 IDC_EDIT1 C++ MFC 控件,我如何获得它的句柄? By which Windows API , Can I done it ?
通过哪个 Windows API,我可以做到吗?
CWnd
派生对象有一个GetSafeHwnd
成员函数来检索该对象的 Windows 句柄,因此如果您的控件在对话框中,您可以像这样检索句柄:
HWND hwnd = GetDlgItem(IDC_EDIT1).GetSafeHwnd();
You can get a handle to a control by calling the Windows API function GetDlgItem :您可以通过调用 Windows API 函数GetDlgItem来获取控件的句柄:
Retrieves a handle to a control in the specified dialog box.
检索指定对话框中控件的句柄。
The CWnd::GetDlgItem class member of the CWnd
class also has an overload to retrieve a control's handle:该的CWnd ::函数GetDlgItem的类成员
CWnd
类也有过载来检索控件的句柄:
HWND hWnd = NULL;
someWnd->GetDlgItem( IDC_EDIT1, &hWnd );
I would like to throw my two cents in, too.我也想投入我的两分钱。
pWnd = GetDlgItem(IDC_EDIT1)
.pWnd = GetDlgItem(IDC_EDIT1)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.