11.04.2014 Views

Advanced MFC Programming

Advanced MFC Programming

Advanced MFC Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3. Splitter Window<br />

}<br />

else CWnd::OnLButtonDown(uFlags, point);<br />

The function implementation is simple. If the splitter window is trackable, we call<br />

CSplitterWnd::OnLButtonDown(…), which will implement tracking if mouse cursor is over the split bar.<br />

Otherwise we bypass this feature by calling function CWnd::OnLButtonDown(…).<br />

If the splitter window is created by the Application Wizard, there will be a command View | Split<br />

implemented in the application. By default, this command gives an alternate way to resize panes by<br />

tracking the split bar. If we want to disable the tracking completely, we also need to disable or remove this<br />

menu command.<br />

Summary<br />

1) To implement static splitter window, we need to derive a class from CView (or other type of view<br />

classes) for each pane, then declare a CSplitterWnd type variable in class CMainFrame. In function<br />

CMainFrame::OnCreateClient(…), we need to call CSplitterWnd::CreateStatic(…) to create the<br />

splitter window and call CSplitterWnd::CreateView(…) to attach a view to each pane.<br />

1) Static splitter window can be nested. This means instead of attaching a view, we can use CSplitterWnd<br />

to further create splitter window within a pane.<br />

1) Creating dynamic splitter window is simple. In order to do this, we need to declare a CSplitterWnd<br />

type variable in class CMainFrame; then in CMainFrame::OnCreateClient(…), we need to call function<br />

CSplitterWnd::Create(…).<br />

1) We can override functions CSplitterWnd::DeleteRow(…) and CSplitterWnd::DeleteColumn(…) to<br />

customize the behavior of split bars.<br />

1) We can override functions CSplitterWnd::OnDrawSplitter(…) and CSplitterWnd::<br />

OnInvertTracker(…) to customize the appearance of split bar, split box, split border and tracker.<br />

1) To disable split bar tracking, we need to call CWnd::OnLButtonDown(…) instead of CSplitterWnd::<br />

OnLbuttonDown(…) when handling message WM_LBUTTONDOWN.<br />

68

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!