怎么取得工具栏内控件的句柄
时间:2011-12-07
来源:互联网
我在我的对话框内的工具栏上手动创建了一些子控件
但是我通过
CComboBox *pComb = (CComboBox *)pDlg->GetDlgItem(IDC_COMBOBOX);//IDC_COMBOBOX 是子控件ID,
却无法取得控件
用
CToolBar *pToolBar = (CToolBar *)pDlg->GetDlgItem(IDR_TOOLBAR); // 这里也取不到
CComboBox *pComb = (CComboBox *)pToolBar->GetDlgItem(IDC_COMBOBOX);
请问这种情况下怎么取得CComboBox控件的句柄或对象?
因为我这里pDlg是CDialog*类型传给外部的,在外面拿不到映射的对象
补充:
能不能通过在对话框类中设置一下,然后在外面能有一个统一地使用GetDlgItem取工具栏的子控件与其它的普通控件?
但是我通过
CComboBox *pComb = (CComboBox *)pDlg->GetDlgItem(IDC_COMBOBOX);//IDC_COMBOBOX 是子控件ID,
却无法取得控件
用
CToolBar *pToolBar = (CToolBar *)pDlg->GetDlgItem(IDR_TOOLBAR); // 这里也取不到
CComboBox *pComb = (CComboBox *)pToolBar->GetDlgItem(IDC_COMBOBOX);
请问这种情况下怎么取得CComboBox控件的句柄或对象?
因为我这里pDlg是CDialog*类型传给外部的,在外面拿不到映射的对象
补充:
能不能通过在对话框类中设置一下,然后在外面能有一个统一地使用GetDlgItem取工具栏的子控件与其它的普通控件?
作者: kbr002 发布时间: 2011-12-07
自已回答了,散分
CWnd* GetDescendantWindow(
int nID,
BOOL bOnlyPerm = FALSE
) const;
Parameters
nID
Specifies the identifier of the control or child window to be retrieved.
bOnlyPerm
Specifies whether the window to be returned can be temporary. If TRUE, only a permanent window can be returned; if FALSE, the function can return a temporary window. For more information on temporary windows see Technical Note 3.
我直接用
CComboBox *pComb = (CComboBox *)pDlg->GetDescendantWindow(IDC_COMBOBOX);
获得
CWnd* GetDescendantWindow(
int nID,
BOOL bOnlyPerm = FALSE
) const;
Parameters
nID
Specifies the identifier of the control or child window to be retrieved.
bOnlyPerm
Specifies whether the window to be returned can be temporary. If TRUE, only a permanent window can be returned; if FALSE, the function can return a temporary window. For more information on temporary windows see Technical Note 3.
我直接用
CComboBox *pComb = (CComboBox *)pDlg->GetDescendantWindow(IDC_COMBOBOX);
获得
作者: kbr002 发布时间: 2011-12-07
还可以用FindWindow等
作者: oyljerry 发布时间: 2011-12-07
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28