5,666,979 members and growing! (15,967 online)
Email Password   helpLost your password?
Desktop Development » Splitter Windows » General     Intermediate

ZSplitter : adding automatic splitting for dialog controls

By Mike Melnikov

A set of classes that provide automatic adding nessasory splitters in your dialogs
VC6, C++Windows, NT4, Win2K, MFC, STL, VS6, Visual Studio, Dev

Posted: 25 Feb 2001
Updated: 28 May 2001
Views: 140,738
Bookmarked: 36 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
23 votes for this Article.
Popularity: 6.13 Rating: 4.50 out of 5
1 vote, 11.1%
1
0 votes, 0.0%
2
1 vote, 11.1%
3
0 votes, 0.0%
4
7 votes, 77.8%
5

Introduction

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.

Sample Image

Using the class

The simplest way is to use the ZSplitterDlgImpl template. You should change:

  • The parent of your dialog ot view class,
  • the constructor implementation,
  • the second parameter in BEGIN_MESSAGE_MAP macros, and
  • the "on init" function of your window.
// 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.

resizable sample

This is a sample of your dialog in resource editor:

in vc++ editor

And user can change it in such way in runtime.

after user manipulations

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.

before moving after moving

To Do list

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?

Note

Make sure to check out the my web site which is more likely to have updates and betas:
http://www.zmike.net

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Mike Melnikov


Mike has been programming in C/C++ for 11 years and Visual C++/MFC for 4 years. His background includes pure and applied mathematics, engineering and physics, and he is currently based in Moscow, Russia.
Occupation: Web Developer
Location: Russian Federation Russian Federation

Other popular Splitter Windows articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 27 (Total in Forum: 27) (Refresh)FirstPrevNext
GeneralMyView1.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const CView::messageMap"memberGertzog15:54 26 Nov '07  
Generalcompiling problems in 2003 .NETmemberpicazo15:39 7 Aug '05  
GeneralRe: compiling problems in 2003 .NETmembergnovice19:47 10 Oct '05  
GeneralRe: compiling problems in 2003 .NETmemberpicazo5:23 11 Oct '05  
GeneralCan not compile under VC7memberSatervalley18:12 13 Aug '02  
GeneralRe: Can not compile under VC7memberchend23:19 30 Oct '02  
GeneralFit a dialog in a View of a WindowmemberAnonymous10:16 17 Apr '02  
GeneralRe: Fit a dialog in a View of a WindowmemberCapsuleDweller2:44 9 May '02  
GeneralZSplit in dynamic dialogmemberEmanuele9:18 17 Apr '02  
GeneralRe: ZSplit in dynamic dialogmemberMike Melnikov2:50 24 Jul '02  
Generalpragma warningmemberJean-Louis Guenego1:37 6 Aug '01  
GeneralSplittermemberPascal Cayrol4:00 18 May '01  
GeneralRe: SplittermemberPascal Cayrol5:14 18 May '01  
GeneralRe: SplittermemberMike Melnikov2:27 30 May '01  
GeneralNow it works with resizable dialog.memberMike Melnikov0:17 7 Mar '01  
Generalwork with resizable dialog?memberphilip andrew14:04 1 Mar '01  
GeneralRe: work with resizable dialog?memberMike Melnikov6:48 2 Mar '01  
GeneralRe: work with resizable dialog?memberMike Melnikov0:25 7 Mar '01  
GeneralRe: work with resizable dialog?memberphilip andrew11:46 13 Mar '01  
GeneralExample As Member tab crashesmemberAnonymous2:49 26 Feb '01  
GeneralRe: Example As Member tab crashesmemberMike Melnikov6:33 26 Feb '01  
GeneralI got the same problem.memberAnonymous14:13 26 Feb '01  
GeneralRe: I got the same problem.memberAnonymous23:51 26 Feb '01  
GeneralRe: I got the same problem.memberMike Melnikov1:20 27 Feb '01  
GeneralCrashes fixedmemberMike Melnikov1:01 27 Feb '01  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 28 May 2001
Editor: Chris Maunder
Copyright 2001 by Mike Melnikov
Everything else Copyright © CodeProject, 1999-2008
Web13 | Advertise on the Code Project