![]() |
Desktop Development »
Splitter Windows »
General
Intermediate
ZSplitter : adding automatic splitting for dialog controlsBy Mike MelnikovA set of classes that provide automatic adding nessasory splitters in your dialogs |
VC6Win2K, MFC, STL, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||
The ZSplitterDlg and ZSplitter classes help
you to add splitters to your dialog, property sheet or any other window.
It splits your controls and makes them movable and resizeable. I think
this way is better than "auto size" contol: it adds a "docking" opportunity. Moreover,
one more control added that add "auto size" option. Finally, you can integrate the ZSplitterDlg with a resizable dialog (for example CResizableDialog by Paolo Messina).
Note that you shouldn't add anything to your resources and shouldn't describe the relations between controls. Just make the corresponding size and position of your controls and use the functions:
void addControls(int count, bool connectVertical, ...); void addControl(int id);
Demo project shows using these automatically added
controls in CDialog, CPropertyPage, CView and CFormView classes.

The simplest way is to use the ZSplitterDlgImpl template. You should change:
BEGIN_MESSAGE_MAP macros, and // in header class CTestDlg1 : public ZSplitterDlgImpl<CPropertyPage> // in source CTestDlg1::CTestDlg1() : /*...*/ ZSplitterDlgImpl<CPropertyPage>(CTestDlg1::IDD) {} BEGIN_MESSAGE_MAP(CTestDlg1, ZSplitterDlgImpl<CPropertyPage>) // ... END_MESSAGE_MAP() BOOL CTestDlg1::OnInitDialog() { // ... and use addControl(s) function here init(); // ... }
The ZSplitterDlgImpl template has a second parameter (ZSplitter2 by default). ZSplitter2 is the implementation of a
spliter control. It has a virtual function OnPaint() - and you can change it's
realisation to have different view of your control (see CMyView1 class in demo project).
The ZSplitterDlgImpl
template helps you to implement splitter controls but you can use its
base ZSplitterDlg class (look for CTestDlg2 class) in demo
project.
I remade a little CResizableDialog with the
permission of the author and you can use it with my splitters: use the ZSplitterDlgResizable class
for this job. (look for CDemoDlg class) in the demo project.

This is a sample of your dialog in resource editor:

And user can change it in such way in runtime.

You should use the addControls or addControl functions to add one control to the
"splitter set" or a group of controls: they will move together. This is an
example which you seen above
addControls(2,false,IDC_LIST6,IDC_LIST7); addControls(2,true,IDC_LIST1,IDC_LIST8); addControl(IDC_LIST9); addControl(IDC_LIST2); addControl(IDC_LIST3); addControl(IDC_LIST4); addControl(IDC_LIST5);
Moreover you can manually add a ZSplitter class (the most common splitter controls)
to a page. Look at the images and in the CTestDlg3 class
of the demo project for details.

I'd like to make the look (color, size, effects) of the splitter more presentable. So I want to get comments from you. First of all: is this technique useful to you?
Make sure to check out the my web site which is more likely to have updates and betas:
http://www.zmike.net
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 28 May 2001 Editor: Chris Maunder |
Copyright 2001 by Mike Melnikov Everything else Copyright © CodeProject, 1999-2009 Web12 | Advertise on the Code Project |