class CMainFrame : public CFrameWnd
{
CObjectViewBar m_wndObjectBar;
CDialogTool m_wndDialogBar;
//class CObjectViewBar : public CBCGPDialogBar
//class CDialogTool : public CBCGPDialogBar
}int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1; ... if(!m_wndObjectBar.Create(_T("属性"),this,TRUE,IDD_OBJECT_BAR,
WS_CHILD |WS_VISIBLE| WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_BCGP_CLOSE | CBRS_BCGP_FLOAT,IDS_VIEW_OBJECT ))
{
TRACE0("未能创建属性框\n");
return -1;
} if(!m_wndDialogBar.Create (this,IDD_DIALOG_BAR,WS_CHILD|WS_VISIBLE|CBRS_BOTTOM,IDD_DIALOG_BAR))
{
TRACE0("未能创建对话条\n");
return -1;
}
ShowControlBar(&m_wndDialogBar,TRUE,FALSE,TRUE);
RecalcLayout();
...
} 我本来希望m_wndDialogBar在状态栏的上面生成,为何程序运行结果m_wndDialogBar总是出现在Frame的Top处,删除注册表重新生成解决方案运行程序也不行(还有一个问题就是我怎么控制m_wndDialogBar的长和宽)
{
CObjectViewBar m_wndObjectBar;
CDialogTool m_wndDialogBar;
//class CObjectViewBar : public CBCGPDialogBar
//class CDialogTool : public CBCGPDialogBar
}int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1; ... if(!m_wndObjectBar.Create(_T("属性"),this,TRUE,IDD_OBJECT_BAR,
WS_CHILD |WS_VISIBLE| WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_BCGP_CLOSE | CBRS_BCGP_FLOAT,IDS_VIEW_OBJECT ))
{
TRACE0("未能创建属性框\n");
return -1;
} if(!m_wndDialogBar.Create (this,IDD_DIALOG_BAR,WS_CHILD|WS_VISIBLE|CBRS_BOTTOM,IDD_DIALOG_BAR))
{
TRACE0("未能创建对话条\n");
return -1;
}
ShowControlBar(&m_wndDialogBar,TRUE,FALSE,TRUE);
RecalcLayout();
...
} 我本来希望m_wndDialogBar在状态栏的上面生成,为何程序运行结果m_wndDialogBar总是出现在Frame的Top处,删除注册表重新生成解决方案运行程序也不行(还有一个问题就是我怎么控制m_wndDialogBar的长和宽)
class CProgStatusBar: public CStatusBar
{
public:
CBCGPDialogBar m_wndDialogBar;
protected:
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); //WM_CREATE和WM_SIZE的
//消 息响应,重载这两个函数
}int CProgStatusBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatusBar::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here lpCreateStruct->style |= WS_CLIPCHILDREN;
CStatusBar::OnCreate(lpCreateStruct);
CRect rc(0,0,0,0);
m_wndDialogBar.Create(WS_CHILD | WS_VISIBLE,rc,this,1);//此处可以设置大小位置
return 0;
}void CProgStatusBar::OnSize(UINT nType, int cx, int cy)
{
CStatusBar::OnSize(nType, cx, cy);
CRect rc;
GetItemRect(0,&rc);
m_wndProgBar.MoveWindow(rc); //此处取的是状态栏第0个位置的大小,也可以设置大小 // TODO: Add your message handler code here
}你说的那个CBCGPDialogBar我没找到相关的,贴上点我自己的看法,希望对能有帮助
DockControlBar()能Dock ControlBar到风格CBRS_ALIGN_xxx指定的可停靠的边界。