Hi to all.
<span lang="EN-US I generated MFC MDI (tabbed) app with ribbon and included output docking pane interface.
<span lang="EN-US Docking pane includes Build, Debug and Find tabs out of box. In my app I would like that my output docking pane have as many tabs of the same name as opened documents, also with same name.
<span lang="EN-US To be clearer if my app has, say two tabbed document open(AppName 1 and
AppName 2) I need to have two tabs in my docking pane named the same. The idea is to show some information about opened views.
<span lang="EN-US The class behind docking pane is âCOutputWndâ on itâs âOnCreateâ function I commented out all below creation of m_wndTabs
<span> (which is CMFCTabCtrl)
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
<span style="color:Blue; if (CDockablePane::OnCreate(lpCreateStruct) == -1)
<span style="color:Blue; return -1;
m_Font.CreateStockObject(DEFAULT_GUI_FONT);
CRect rectDummy;
rectDummy.SetRectEmpty();
<span style="color:Green; // Create tabs window:
<span style="color:Blue; if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, <span style="color:Blue; this, 1))
{
TRACE0(<span style="color:#A31515; "Failed to create output tab windown");
<span style="color:Blue; return -1; <span style="color:Green; // fail to create
}
<span style="color:Green; // Create output panes:
<span style="color:Green; //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
<span style="color:Green; //if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) ||
<span style="color:Green; // !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) ||
<span style="color:Green; // !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4))
<span style="color:Green; //{
<span style="color:Green; // TRACE0("Failed to create output windowsn");
<span style="color:Green; // return -1; // fail to create
<span style="color:Green; //}
<span style="color:Green; //m_wndOutputBuild.SetFont(&m_Font);
<span style="color:Green; //m_wndOutputDebug.SetFont(&m_Font);
<span style="color:Green; //m_wndOutputFind.SetFont(&m_Font);
<span style="color:Green; //CString strTabName;
<span style="color:Green; //BOOL bNameValid;
<span style="color:Green; // Attach list windows to tab:
<span style="color:Green; //bNameValid = strTabName.LoadString(IDS_BUILD_TAB);
<span style="color:Green; //ASSERT(bNameValid);
<span style="color:Green; //m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0);
<span style="color:Green; //bNameValid = strTabName.LoadString(IDS_DEBUG_TAB);
<span style="color:Green; //ASSERT(bNameValid);
<span style="color:Green; //m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1);
<span style="color:Green; //bNameValid = strTabName.LoadString(IDS_FIND_TAB);
<span style="color:Green; //ASSERT(bNameValid);
<span style="color:Green; //m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2);
<span style="color:Blue; return 0;
}
[/code]
<span lang="EN-US , and I added a member function called âDodajNovi(CString title)â where I placed code for adding a tab. This member function Iâm calling from âCMyAppView::OnInitialUpdate()â after I get document title (eg.
AppName 1).
<span lang="EN-US
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; void COutputWnd:odajNovi(CString title)
{
m_Font.CreateStockObject(DEFAULT_GUI_FONT);
COutputList m_NewList;
CRect rectDummy;
rectDummy.SetRectEmpty();
<span style="color:Blue; const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
<span style="color:Blue; if(!m_NewList.Create(dwStyle, rectDummy, &m_wndTabs, atoi(title)+1))
{
TRACE0(<span style="color:#A31515; "Failed to create new output tab windown");
<span style="color:Blue; return;
}
m_NewList.SetFont(&m_Font);
m_wndTabs.AddTab(&m_NewList, title, (UINT)-1);
}
[/code]
The problem is when adding second tab app crashes.
From call stack:
<div style="color:Black;background-color:White; <pre>
> Statistika.exe!CWnd::SetWindowPos(<span style="color:Blue; const CWnd * pWndInsertAfter=0x00000000, <span style="color:Blue; int x=3, <span style="color:Blue; int y=3, <span style="color:Blue; int cx=1594, <span style="color:Blue; int cy=57, <span style="color:Blue; unsigned <span style="color:Blue; int nFlags=20) Line 324 + 0x24 bytes C++
Statistika.exe!CMFCTabCtrl::RecalcLayout() Line 1880 C++
Statistika.exe!CMFCBaseTabCtrl::InsertTab(CWnd * pNewWnd=0x0013eb60, <span style="color:Blue; const <span style="color:Blue; char * lpszTabLabel=0x0181d990, <span style="color:Blue; int nInsertAt=1, <span style="color:Blue; unsigned <span style="color:Blue; int uiImageId=4294967295, <span style="color:Blue; int bDetachable=0) Line 319 C++
Statistika.exe!CMFCBaseTabCtrl::AddTab(CWnd * pNewWnd=0x0013eb60, <span style="color:Blue; const <span style="color:Blue; char * lpszName=0x0181d990, <span style="color:Blue; unsigned <span style="color:Blue; int uiImageId=4294967295, <span style="color:Blue; int bDetachable=1) Line 254 C++
Statistika.exe!COutputWnd:odajNovi(ATL::CStringT<<span style="color:Blue; char,StrTraitMFC<<span style="color:Blue; char,ATL::ChTraitsCRT<<span style="color:Blue; char> > > title=<span style="color:#A31515; "Statistika2") Line 129 + 0x2d bytes C++
[/code]
Where am I failing?
Thanks in advance.
View the full article
<span lang="EN-US I generated MFC MDI (tabbed) app with ribbon and included output docking pane interface.
<span lang="EN-US Docking pane includes Build, Debug and Find tabs out of box. In my app I would like that my output docking pane have as many tabs of the same name as opened documents, also with same name.
<span lang="EN-US To be clearer if my app has, say two tabbed document open(AppName 1 and
AppName 2) I need to have two tabs in my docking pane named the same. The idea is to show some information about opened views.
<span lang="EN-US The class behind docking pane is âCOutputWndâ on itâs âOnCreateâ function I commented out all below creation of m_wndTabs
<span> (which is CMFCTabCtrl)
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
<span style="color:Blue; if (CDockablePane::OnCreate(lpCreateStruct) == -1)
<span style="color:Blue; return -1;
m_Font.CreateStockObject(DEFAULT_GUI_FONT);
CRect rectDummy;
rectDummy.SetRectEmpty();
<span style="color:Green; // Create tabs window:
<span style="color:Blue; if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, <span style="color:Blue; this, 1))
{
TRACE0(<span style="color:#A31515; "Failed to create output tab windown");
<span style="color:Blue; return -1; <span style="color:Green; // fail to create
}
<span style="color:Green; // Create output panes:
<span style="color:Green; //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
<span style="color:Green; //if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) ||
<span style="color:Green; // !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) ||
<span style="color:Green; // !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4))
<span style="color:Green; //{
<span style="color:Green; // TRACE0("Failed to create output windowsn");
<span style="color:Green; // return -1; // fail to create
<span style="color:Green; //}
<span style="color:Green; //m_wndOutputBuild.SetFont(&m_Font);
<span style="color:Green; //m_wndOutputDebug.SetFont(&m_Font);
<span style="color:Green; //m_wndOutputFind.SetFont(&m_Font);
<span style="color:Green; //CString strTabName;
<span style="color:Green; //BOOL bNameValid;
<span style="color:Green; // Attach list windows to tab:
<span style="color:Green; //bNameValid = strTabName.LoadString(IDS_BUILD_TAB);
<span style="color:Green; //ASSERT(bNameValid);
<span style="color:Green; //m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0);
<span style="color:Green; //bNameValid = strTabName.LoadString(IDS_DEBUG_TAB);
<span style="color:Green; //ASSERT(bNameValid);
<span style="color:Green; //m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1);
<span style="color:Green; //bNameValid = strTabName.LoadString(IDS_FIND_TAB);
<span style="color:Green; //ASSERT(bNameValid);
<span style="color:Green; //m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2);
<span style="color:Blue; return 0;
}
[/code]
<span lang="EN-US , and I added a member function called âDodajNovi(CString title)â where I placed code for adding a tab. This member function Iâm calling from âCMyAppView::OnInitialUpdate()â after I get document title (eg.
AppName 1).
<span lang="EN-US
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; void COutputWnd:odajNovi(CString title)
{
m_Font.CreateStockObject(DEFAULT_GUI_FONT);
COutputList m_NewList;
CRect rectDummy;
rectDummy.SetRectEmpty();
<span style="color:Blue; const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
<span style="color:Blue; if(!m_NewList.Create(dwStyle, rectDummy, &m_wndTabs, atoi(title)+1))
{
TRACE0(<span style="color:#A31515; "Failed to create new output tab windown");
<span style="color:Blue; return;
}
m_NewList.SetFont(&m_Font);
m_wndTabs.AddTab(&m_NewList, title, (UINT)-1);
}
[/code]
The problem is when adding second tab app crashes.
From call stack:
<div style="color:Black;background-color:White; <pre>
> Statistika.exe!CWnd::SetWindowPos(<span style="color:Blue; const CWnd * pWndInsertAfter=0x00000000, <span style="color:Blue; int x=3, <span style="color:Blue; int y=3, <span style="color:Blue; int cx=1594, <span style="color:Blue; int cy=57, <span style="color:Blue; unsigned <span style="color:Blue; int nFlags=20) Line 324 + 0x24 bytes C++
Statistika.exe!CMFCTabCtrl::RecalcLayout() Line 1880 C++
Statistika.exe!CMFCBaseTabCtrl::InsertTab(CWnd * pNewWnd=0x0013eb60, <span style="color:Blue; const <span style="color:Blue; char * lpszTabLabel=0x0181d990, <span style="color:Blue; int nInsertAt=1, <span style="color:Blue; unsigned <span style="color:Blue; int uiImageId=4294967295, <span style="color:Blue; int bDetachable=0) Line 319 C++
Statistika.exe!CMFCBaseTabCtrl::AddTab(CWnd * pNewWnd=0x0013eb60, <span style="color:Blue; const <span style="color:Blue; char * lpszName=0x0181d990, <span style="color:Blue; unsigned <span style="color:Blue; int uiImageId=4294967295, <span style="color:Blue; int bDetachable=1) Line 254 C++
Statistika.exe!COutputWnd:odajNovi(ATL::CStringT<<span style="color:Blue; char,StrTraitMFC<<span style="color:Blue; char,ATL::ChTraitsCRT<<span style="color:Blue; char> > > title=<span style="color:#A31515; "Statistika2") Line 129 + 0x2d bytes C++
[/code]
Where am I failing?
Thanks in advance.
View the full article