Thierry SUPPLISSON
June 5th, 1998, 11:40 AM
I experienced two little problems with the CFlatToolBar code when positioning vertically the toolbar.
- the toolbar does not seem to take account of the separator width
- the position of the first button next to the grip is incorrect when you moce the toolbar in the following position consecutively
Vertical -> Floating -> Horizontal
Here is a working correction:
CFlatToolBar::CFlatToolBar()
:CToolBar()
{
m_bOldFloating=FALSE;
}
// Because buttons are transparent, we need to repaint background on size or move
VOID CFlatToolBar::OnWindowPosChanging(LPWINDOWPOS pWindowPos)
{
// default processing
if(m_bOldFloating!=(IsFloating()?TRUE:FALSE))
{
m_bOldFloating=!m_bOldFloating;
pWindowPos->flags|=SWP_DRAWFRAME;
}
CToolBar::OnWindowPosChanging(pWindowPos);
// horizontal vs vertical
BOOL bIsVertical = (m_dwStyle & CBRS_ORIENT_HORZ) == 0;
// get number of buttons
LONG nIndexMax = (LONG)DefWindowProc(TB_BUTTONCOUNT, 0, 0);
LONG nIndex;
// try each button
if(bIsVertical && !(pWindowPos->flags & SWP_NOSIZE) )
{
for (nIndex = 0; nIndex cy+=3;
}
}
}
RepaintBackground();
}
and in the class declaration
...
CFlatToolBar();
BOOL m_bOldFloating;
...
- the toolbar does not seem to take account of the separator width
- the position of the first button next to the grip is incorrect when you moce the toolbar in the following position consecutively
Vertical -> Floating -> Horizontal
Here is a working correction:
CFlatToolBar::CFlatToolBar()
:CToolBar()
{
m_bOldFloating=FALSE;
}
// Because buttons are transparent, we need to repaint background on size or move
VOID CFlatToolBar::OnWindowPosChanging(LPWINDOWPOS pWindowPos)
{
// default processing
if(m_bOldFloating!=(IsFloating()?TRUE:FALSE))
{
m_bOldFloating=!m_bOldFloating;
pWindowPos->flags|=SWP_DRAWFRAME;
}
CToolBar::OnWindowPosChanging(pWindowPos);
// horizontal vs vertical
BOOL bIsVertical = (m_dwStyle & CBRS_ORIENT_HORZ) == 0;
// get number of buttons
LONG nIndexMax = (LONG)DefWindowProc(TB_BUTTONCOUNT, 0, 0);
LONG nIndex;
// try each button
if(bIsVertical && !(pWindowPos->flags & SWP_NOSIZE) )
{
for (nIndex = 0; nIndex cy+=3;
}
}
}
RepaintBackground();
}
and in the class declaration
...
CFlatToolBar();
BOOL m_bOldFloating;
...