|
The sample project does not work on VC6.0 . When I change it to fit VC6.0, it is so nice. But it does not repaint when the main window is maximized or minimized. Please update a newer version, Dirk Clemens.
|
|
|
|
|
hy, at first sorry for my bad englisch. i'm still learning
So my problem is, my prog crashed when i click on X.
History:
I have made a Tree in the first tab. When i doubleclick on a Item, my prog get the text from the Item an write the text in the Document.
This works fine & without problems.
But click i now on X for closed my prog i became a warning Debug Assertion Failed!
The Debug show me the file "\VC98\MFC\SRC\WINFRAME.CPP"
and the function
<br />
<br />
void CFrameWnd::DestroyDockBars()<br />
{<br />
CPtrList listDockBars;<br />
POSITION pos = m_listControlBars.GetHeadPosition();<br />
while (pos != NULL)<br />
{<br />
CDockBar* pDockBar = (CDockBar*)m_listControlBars.GetNext(pos);<br />
ASSERT(pDockBar != NULL);<br />
if (pDockBar->IsDockBar())<br />
listDockBars.AddTail(pDockBar);<br />
}<br />
pos = listDockBars.GetHeadPosition();<br />
while (pos != NULL)<br />
{<br />
CDockBar* pDockBar = (CDockBar*)listDockBars.GetNext(pos);<br />
if (pDockBar->m_bFloating)<br />
{<br />
CFrameWnd* pFrameWnd = pDockBar->GetParentFrame();<br />
ASSERT_VALID(pFrameWnd);<br />
pFrameWnd->DestroyWindow();<br />
}<br />
else<br />
pDockBar->DestroyWindow();<br />
}<br />
}
the line in Debug how is wrong is by ASSERT(pDockBar != NULL);
in Debug pDockBar 0x00000000 {CDockBar hWnd = ???}
but start i my prog and closed it before i doubleclick on TreeView first Tab, my prog closed without warning.
And i can write into Doc & close my prog without warning.
The prog only crashed if i doubleclick on the TreeView and close it than.
can someone help me please
|
|
|
|
|
Hi,
I've been reading ppl struggling with drawing bugs, the flaw was in CSizingTabCtrlBar::OnSize, actually the tab wnd was covering the whole bar.
The layout code below sounds mutch better.
Define margins as needed and,
Enjoy!
void CSizingTabCtrlBar::OnSize(UINT nType, int cx, int cy)
{
CSizingControlBar::OnSize(nType, cx, cy);
CRect crect;
GetClientRect(crect);
crect.DeflateRect(TAB_XMARGIN,VIEW_YMARGIN,TAB_XMARGIN,TAB_YMARGIN);
CRect trect;
m_tabctrl.GetItemRect(0,trect);
trect = CRect(TAB_XMARGIN,(crect.Height() - TAB_YMARGIN) - trect.Height(),crect.Width() - 2 * TAB_XMARGIN, crect.Height() - TAB_YMARGIN);
m_tabctrl.MoveWindow(trect);
CRect vrect = crect;
vrect.DeflateRect(VIEW_XMARGIN,VIEW_YMARGIN,VIEW_XMARGIN,VIEW_YMARGIN + trect.Height() + TAB_YMARGIN);
CWnd *pWnd;
for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos))
{
pWnd = m_views.GetAt(pos)->pWnd;
pWnd->MoveWindow(vrect);
}
}
|
|
|
|
|
In your function:
TAB_XMARGIN
TAB_YMARGIN
VIEW_XMARGIN
VIEW_YMARGIN
are all undefined.
|
|
|
|
|
They just are placeholders ..
Just put whatever value/CONSTANT/variable you need/want...
|
|
|
|
|
I think here is a copy and paste error:
crect.DeflateRect(TAB_XMARGIN,VIEW_YMARGIN,TAB_XMARGIN,TAB_YMARGIN);
I replaced that with TAB_YMARGIN which worked fine.
|
|
|
|
|
Thanks for useful code. There are two small issues with controlbar when it is floating. The first one appears when closing main app, the second one when closing floating bar and focus was set in one of its view. The possible solution for first problem is to dock bar before exit:
void CMainFrame::OnClose()
{
if(m_wndSTCBar.IsFloating())
DockControlBar(&m_wndSTCBar, AFX_IDW_DOCKBAR_LEFT);
CFrameWnd::OnClose();
}
The possible solution to second issue is to set focus to MainFrame view when floating bar is being closed:
void CSizingTabCtrlBar::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
if ( IsFloating() && (lpwndpos->flags & SWP_HIDEWINDOW) )
{
CMainFrame *pFrame = (CMainFrame*)GetTopLevelFrame();
pFrame->SetActiveView(pFrame->m_cActiveView);
}
CSizingControlBar::OnWindowPosChanging(lpwndpos);
}
where m_cActiveView is a CView* object that need to be pointed to MainFrame View.
|
|
|
|
|
Is it possible to dock the window to the top or bottom of the frame
|
|
|
|
|
I have used this class, but i am faced with one problem,
I have a SDI application, and i have two other docking views, one on the left, and one in the bottom,
I have to refresh the tree controls, periodically say after every 4-5 seconds, and i access the Doc class, to get the data from there.
The problem is, that it all works fine, however when i click on the left tabcontrol view, the Doc pointer retrieved is NULL, and the application crashes, I cannot guess why a mouse click would cause such a behaviour,
I have also noticed, that if the dockign window is not docked and is floating the click of the mouse will not crash the prob, and the Doc pointer is retrieved correct,
What might be the reason to it ?
I guess it has some ting to do the way messages are routed from the windows ?
|
|
|
|
|
the sizing control tab bar doesn't seem to give up the wheel mouse when i click in another view (CScollView). Any ideas how to make it give up the wheel mouse?
thx steve
|
|
|
|
|
When I click on the X after making the bar float how do I show it again. It doesnt seem to act lick a normal toolbar.
D-MD
|
|
|
|
|
//when you click Button named "show/hide this Wnd"
void CMainFrame::OnButtonInfospace()
{
// TODO: Add your command handler code here
if (m_WndShowHDX.IsWindowVisible() == TRUE)
ShowControlBar(&m_WndShowHDX, FALSE, FALSE); //hide the Wnd
else
ShowControlBar(&m_WndShowHDX, TRUE, FALSE);//show the Wnd
RecalcLayout();
}
void CMainFrame::OnUpdateButtonInfospace(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(m_WndShowHDX.IsWindowVisible());
}
xiaobin
|
|
|
|
|
Hi, I found <big>it does not work well in VS.net 2003</big> ,It compile well but not run well !May anyone help me to solve it?
Thank you!!
|
|
|
|
|
I found a similar problem.
I open the demo by vs2003 and convert the version by vs2003, I found it works good.
But if I create a new solution by vs2003 and add the CSizingTabCtrlBar into it, it can't work properly when maximizing the window, the size of the tabctrl is wrong.
I can't solve this problem, may anyone know how to do?
3x!
|
|
|
|
|
The update problem of the views is caused occurs because they are given the wrong parent window.
replacing:
if (!pWnd->Create(NULL, NULL, dwStyle, rect, this, 0, pContext))<br />
with
if (!pWnd->Create(NULL, NULL, dwStyle, rect, &m_tabctrl, 0, pContext))
solves the problem.
http://www.codeguru.com/mfc/comments/27713.shtml
|
|
|
|
|
Right, but requires also a small change in layout in OnSize. Here a full OnSize function (with a change from post above and new positions)
void CSizingTabCtrlBar::OnSize(UINT nType, int cx, int cy)
{
CSizingControlBar::OnSize(nType, cx, cy);
int bottom = (IsHorzDocked() || IsFloating()) ? cy - 14 : cy - 18;
m_tabctrl.MoveWindow(7, 7, cx - 14, bottom);
CWnd *pWnd;
for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos))
{
pWnd=m_views.GetAt(pos)->pWnd;
pWnd->MoveWindow(2, 9, cx-21, bottom-36);
}
}
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
this change is ok, but what if the font changes? or the tab size changes? a better fix would be:
void CSizingTabCtrlBar::OnSize(UINT nType, int cx, int cy)<br>
{<br>
CSizingControlBar::OnSize(nType, cx, cy);<br><br>
int bottom = (IsHorzDocked() || IsFloating()) ? cy - 14 : cy - 18;<br><br>
m_tabctrl.MoveWindow(7, 7, cx - 14, bottom);<br><br>
CRect r;<br>
m_tabctrl.GetClientRect(&r);<br>
m_tabctrl.AdjustRect(FALSE, &r);<br><br>
CWnd *pWnd;<br>
for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos))<br>
{<br>
pWnd=m_views.GetAt(pos)->pWnd;<br>
pWnd->MoveWindow(r.top, r.left, r.Width(), r.Height());<br>
}<br>
}<br>
Andy
|
|
|
|
|
|
resource.h include it, but compile error...
what is IDW_PROP_BAR , where is it?
thanks!
Great C++!
|
|
|
|
|
IDW_PROP_BAR is the name of the Tab Control Identifier, and it appears in "resource.h" and CMainFrame::OnCreate.
When the Tab Control is being created, it needs to have a name that will identify it, which is what IDW_PROP_BAR is. It could have been any name, but that's the one the person writing the program chose.
William
Fortes in fide et opere!
|
|
|
|
|
At the last line of:
void CSizingTabCtrlBar::OnSize(UINT nType, int cx, int cy)
At the following line: Invalidate();
To prevent the defect in the border while enlarging the control.
|
|
|
|
|
HI, everybody?
I'm a beginner at mfc..
I think it is very useful code!!
It is compiled and build very well..
But,I can't use it..
Because it doesn't work and show following error message..
//"Debug Assertion Failed!!"
//"File name : barcore.cpp"
//"Line : 987"
And the line 987 above is followed..
ASSERT((m_dwStyle & CBRS_ALL) == m_dwStyle);
So I don't know how to debug it..
Would you , professional programer, please help me?;)
I'll be waiting for reply..
PS : I use microsoft Visual C++ 6.0 compiler.
I Downloaded sourcecoed(46k) and compiled without any change.
|
|
|
|
|
Hi ParkSK,
Try to do following:
BOOL CSizingControlBar::Create(CWnd* pParentWnd, CSize sizeDefault, UINT nID, DWORD dwStyle)
{
ASSERT_VALID(pParentWnd); // must have a parent
ASSERT (!((dwStyle & CBRS_SIZE_FIXED) && (dwStyle & CBRS_SIZE_DYNAMIC)));
// save the style
// m_dwStyle = dwStyle;
dwStyle &= ~CBRS_ALL;
dwStyle |= CCS_NOPARENTALIGN|CCS_NOMOVEY|CCS_NODIVIDER|CCS_NORESIZE;
m_sizeHorz = sizeDefault;
m_sizeVert = sizeDefault;
m_sizeFloat = sizeDefault;
CString wndclass = AfxRegisterWndClass(CS_DBLCLKS, LoadCursor(NULL, IDC_ARROW),
CreateSolidBrush(GetSysColor(COLOR_BTNFACE)), 0);
bool bTest = ((m_dwStyle & CBRS_ALL) == m_dwStyle);
if (!CWnd::Create(wndclass, NULL, dwStyle, CRect(0,0,0,0),
pParentWnd, nID))
return FALSE;
return TRUE;
}
That means to comment the line 'm_dwStyle = dwStyle;' which saves the style in advance.
Jawid
|
|
|
|
|
Thank you very much.
Just two slashes(//) make it great!!
|
|
|
|
|
Thx, it works for me too !
Thank U again
Gremy
|
|
|
|
|