MFC 中简单的问题
我现在在一个对话框中,点击OK按钮,然后再住框架中加入一个DialogBar,我的想法是得到CMainFrame的指针,然后创—ialogBar,代码如下:
CMainFrame *pFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd);
if (!m_wndStrategyBar.Create(_T("2???"), this, 127))
{
TRACE0("Failed to create strategy bar\n");
}
m_wndStrategyBar.SetSCBStyle(m_wndStrategyBar.GetSCBStyle() | SCBS_SIZECHILD);
m_wndStrategyBar.SetBarStyle(m_wndStrategyBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
pFrame->AddControlBar(&m_wndStrategyBar);
m_wndStrategyBar.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
pFrame->DockControlBar(&m_wndStrategyBar,AFX_IDW_DOCKBAR_LEFT);
此时点击OK按钮,没有任何变化...麻烦明白的人指点一下。。。
上面代码是可行的,已经试过了,你的问题主要有两个,第一:要把m_wndStrategyBar定义到CMainFram的头文件中。第二:Create创建时把pFrame取代this.