I would like to use CMDITabBar (from WinMerge) into a MFC MDI test application.
Here is the test app: https://1drv.ms/u/c/dedcb6ef190b8fd4/ESppBUOCT-hJog-OyL43QXsBooSUM0liWkY9PHAeQo1FBw?e=BeSIzC
The code for integration (CMainFrame
header):
protected: // control bar embedded members
CMFCMenuBar m_wndMenuBar;
CMFCStatusBar m_wndStatusBar;
CMDITabBar m_wndTabBar; // <---
In implementation file:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndTabBar.Create(this))
{
TRACE(_T("Failed to create tab bar\n"));
return -1; // fail to create
}
m_wndTabBar.SetAutoMaxWidth(false);
....
But the tab control does not show up. I am thinking that is because the m_wndTabBar
should be docked, which I also tried:
// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
EnableDocking(CBRS_ALIGN_ANY);
m_wndTabBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndTabBar, AFX_IDW_DOCKBAR_TOP);
then, I got:
File: D:\a\_work\1\s\src\vctools\VC7Libs\Ship\ATLMFC\Src\MFC\winfrm2.cpp
Line: 92
ASSERT(pDockBar != NULL);
// assert fails when initial CBRS_ of bar does not
// match available docking sites, as set by EnableDocking()
It is possible to use this CMDITabBar
into a simple MDI MFC app? Can you help here?
P.S.
Here is the defintion of CMDITabs
:
class CMDITabBar : public CControlBar
{
DECLARE_DYNAMIC(CMDITabBar)
private:
bool m_bOnTitleBar;
CMyTabCtrl m_tabCtrl;
CFont m_font;
CTitleBarHelper m_titleBar;
public:
CMDITabBar()
: m_bOnTitleBar(true)
{}
virtual ~CMDITabBar() {}
BOOL Update(bool bOnTitleBar, bool bMaxmized);
void UpdateActive(bool bActive);
BOOL Create(CMDIFrameWnd* pParentWnd);
void UpdateTabs() { m_tabCtrl.UpdateTabs(); }
bool GetAutoMaxWidth() const { return m_tabCtrl.GetAutoMaxWidth(); }
void SetAutoMaxWidth(bool bAutoMaxWidth) { m_tabCtrl.SetAutoMaxWidth(bAutoMaxWidth); }
int GetItemCount() const { return m_tabCtrl.GetItemCount(); }
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler) {}
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
protected:
//{{AFX_MSG(CMDITabBar)
afx_msg LRESULT OnNcHitTest(CPoint point);
afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
afx_msg void OnNcMouseLeave();
afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnNcRButtonUp(UINT nHitTest, CPoint point);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
};