怎么取得工具栏内控件的句柄

kbr002 2011-12-07 10:37:48
我在我的对话框内的工具栏上手动创建了一些子控件

但是我通过
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取工具栏的子控件与其它的普通控件?
...全文
157 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2011-12-07
  • 打赏
  • 举报
回复
孙鑫老师视频里面貌似有将 :)
oyljerry 2011-12-07
  • 打赏
  • 举报
回复
还可以用FindWindow等
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);
获得

15,979

社区成员

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

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