Earlier today, someone asked on the vc.mfc NG how he can lock his splitter windows. I replied to him asking him to handle WM_SETCURSOR, WM_LBUTTONDOWN and WM_LBUTTONUP in a CSplitterWnd derived class and to call the base class implementation only if locking is disabled. Later, I decided to try it out and found that there was no need to handle WM_LBUTTONUP but that WM_MOUSEMOVE should be handled. I replied to him again, correcting my earlier post. For future reference, I thought it best to blog about it here and the relevant code snippets are posted below :-
class CLockSplitterWnd : public CSplitterWnd;
//. . .
BEGIN_MESSAGE_MAP(CLockSplitterWnd, CSplitterWnd)
ON_WM_LBUTTONDOWN()
ON_WM_SETCURSOR()
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
//. . .
void CLockSplitterWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
if(m_bLocked)
CWnd::OnLButtonDown(nFlags, point);
else
CSplitterWnd::OnLButtonDown(nFlags, point);
}
BOOL CLockSplitterWnd::OnSetCursor(CWnd* pWnd,
UINT nHitTest, UINT message)
{
if(m_bLocked)
return CWnd::OnSetCursor(pWnd, nHitTest, message);
else
return CSplitterWnd::OnSetCursor(pWnd, nHitTest, message);
}
void CLockSplitterWnd::OnMouseMove(UINT nFlags, CPoint point)
{
if(m_bLocked)
CWnd::OnMouseMove(nFlags, point);
else
CSplitterWnd::OnMouseMove(nFlags, point);
}
actually, there is an article about this in msdn: the February 2001 issue of MSDN Magazine
Thank You!