CDialogBar中的CButton的问题

hmt 2003-04-28 12:05:02
我继承了CDialogBar类,在其中家了个CButton成员变量,
我用CButton 的create来创建button,用ON_BN_CLICKED来接收消息,
可总是不行。代码如下
mybutton.Create(_T("mybutton"),BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,
rect,this,IDC_BUTTON);

ON_BN_CLICKED(IDC_BUTTON,OnPushBt)
当我把IDC_BUTTON 设成0时button才被激活,但按下后,没有调用OnPushBt()
我都搞了一个上午了,还没搞定,望各位指点,十分感谢

...全文
37 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
蒋晟 2003-04-29
  • 打赏
  • 举报
回复
can not assign CDialog to CDialogBar
to derive your own CDialogBar class,see More Information section in MSDN Knowledge Base Q185672 HOWTO: How to Initialize Child Controls in a Derived CDialogBar
see also Q99161 HOWTO: Derive From Classes not Listed in ClassWizard
hmt 2003-04-29
  • 打赏
  • 举报
回复
to jiangsheng(蒋晟.Net)
如何把创建好的CDialog 对象指派给CDialogBar.
我试过用CDialogBar::attach(mydialog.m_hWnd),但是不行,要
如何做?
蒋晟 2003-04-28
  • 打赏
  • 举报
回复
ON_BN_CLICKED应该放到CDialogBar的父窗口(通常是框架)中
CCBeyond 2003-04-28
  • 打赏
  • 举报
回复
应该用ON_COMMAND()接收消息
蒋晟 2003-04-28
  • 打赏
  • 举报
回复
While it is normal to derive your own dialog classes from CDialog, you do not typically derive your own class for a dialog bar. Dialog bars are extensions to a main window and any dialog-bar control-notification messages, such as BN_CLICKED or EN_CHANGE, will be sent to the parent of the dialog bar, the main window.

See Visual C++ MFC Samples CTRLBARS Sample: Illustrates Custom Control Bars
hongliang13 2003-04-28
  • 打赏
  • 举报
回复
请问蒋昊.Net,你说的那个方法完全可行!但是我不会做。。。。

具体怎么把那个东西加到MainFrame中呢?
hmt 2003-04-28
  • 打赏
  • 举报
回复
有没有方法在CDialogBar内部接收消息呢?
我也用过ON_COMMAND(),但是也不行啊。

15,978

社区成员

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

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