Eric Hu
May 7th, 1998, 01:29 AM
Must,You defined one bool flag and dockbar ID in your class.
like this:
class CFlatToolBar : public CToolBar
{
...
protected:
BOOL m_bInRecalcNC;
UINT m_nDockBarID;
...
}
By default,the m_bInRecalcNC is FALSE ,then the m_nDockBarID
you don't need to deine it.
void CFlatToolBar::OnWindowPosChanged(LPWINDOWPOS lpwp)
{
CToolBar::OnWindowPosChanged(lpwp);
if (m_bInRecalcNC) return;
UINT nDockBarID = GetParent()->GetDlgCtrlID();
// Return if dropped at same location
if (nDockBarID == m_nDockBarID // no docking side change
&& (lpwp->flags & SWP_NOSIZE) // no size change
&& ((m_dwStyle & CBRS_BORDER_ANY) != CBRS_BORDER_ANY))
return;
m_nDockBarID = nDockBarID;
// Force recalc the non-client area
m_bInRecalcNC = TRUE; //<---- Lock no coming again...
SetWindowPos(NULL, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
SWP_NOACTIVATE | SWP_FRAMECHANGED);
m_bInRecalcNC = FALSE;
}
like this:
class CFlatToolBar : public CToolBar
{
...
protected:
BOOL m_bInRecalcNC;
UINT m_nDockBarID;
...
}
By default,the m_bInRecalcNC is FALSE ,then the m_nDockBarID
you don't need to deine it.
void CFlatToolBar::OnWindowPosChanged(LPWINDOWPOS lpwp)
{
CToolBar::OnWindowPosChanged(lpwp);
if (m_bInRecalcNC) return;
UINT nDockBarID = GetParent()->GetDlgCtrlID();
// Return if dropped at same location
if (nDockBarID == m_nDockBarID // no docking side change
&& (lpwp->flags & SWP_NOSIZE) // no size change
&& ((m_dwStyle & CBRS_BORDER_ANY) != CBRS_BORDER_ANY))
return;
m_nDockBarID = nDockBarID;
// Force recalc the non-client area
m_bInRecalcNC = TRUE; //<---- Lock no coming again...
SetWindowPos(NULL, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
SWP_NOACTIVATE | SWP_FRAMECHANGED);
m_bInRecalcNC = FALSE;
}