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的长和宽)

解决方案 »

  1.   

    应该重写状态栏类,将wndDialogBar作为其成员,然后重载CStatusBar的Create()函数和OnSize()函数,用来控制在状态栏的哪个位置的
    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我没找到相关的,贴上点我自己的看法,希望对能有帮助
      

  2.   

    谢谢tlm38025这位热心的朋友,问题已解决,添加语句 DockControlBar(&m_wndDialogBar);就OK啦
    DockControlBar()能Dock ControlBar到风格CBRS_ALIGN_xxx指定的可停靠的边界。
      

  3.   

    自己顶一下,怎么去掉CBCGPDialogBar的标题栏还有关闭按钮,在Create()函数中改变nStyle参数,怎么效果都不变,网上这方面的资料太少了,它的说明文档也说明的不是很详细,请高手指教!