如上
添加一个click的消息映射给Button就行了.
你的button必须要相应消息,否则就是不可用的。
应该是命令路由的问题。
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// TODO: Add your specialized code here and/or call the base class
if (m_DlgBar.OnCmdMsg(nID,nCode,pExtra,pHandlerInfo))
return TRUE;
return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
这是一个有关DialogBar Toolbar 的例子
http://www.ccw.com.cn/htm/app/down/4d_s1.zip
运行时不能用的很大情况,是你没有为这个button添加click的消息映射。
添加后就可以了。但要注意,你的click的消息映射添加的位置。
//Create DiaglogBar
if ( !m_wndDialogBar.Create( this, IDD_PANOVIEW_DBAR, CBRS_TOP, IDD_PANOVIEW_DBAR ) ) {
TRACE0( "Failed to create dialogbar \n" );
return -1;
}
如果,你的create的第一个参数是指向mainfrm的话,就要把click的消息映射添加到mainfrm的class中。