我继承了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()
我都搞了一个上午了,还没搞定,望各位指点,十分感谢

解决方案 »

  1.   

    ON_BN_CLICKED应该放到CDialogBar的父窗口(通常是框架)中
      

  2.   

    有没有方法在CDialogBar内部接收消息呢?
    我也用过ON_COMMAND(),但是也不行啊。
      

  3.   

    请问蒋昊.Net,你说的那个方法完全可行!但是我不会做。具体怎么把那个东西加到MainFrame中呢?
      

  4.   

    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
      

  5.   

    to  jiangsheng(蒋晟.Net)
       如何把创建好的CDialog 对象指派给CDialogBar.
    我试过用CDialogBar::attach(mydialog.m_hWnd),但是不行,要
    如何做?
      

  6.   

    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