Introduction

I'm a student and very interested in VC++. I often enter this web site to get
free source code. I was in need of a splitter in a dialog.
I downloaded one but it's very complex and I felt it was difficult to use the
control (although
it's very powerful) so I made one for myself. Maybe, it's not useful for you,
but if there's
only one person who thinks it's useful, I will be very happy. Sometimes
you don't need good skill, just a good idea, and by this simple way a useful
piece of code will be produced. My splitter control is one of this kind.

How to use the CSplitterControl class

First of all, add two files SplitterControl.h and SplitterControl.cpp to the
project. Remember to add #include "splittercontrol.h" to the header
file of the class which uses it.

Add member varible to the dialog class

protected:
CSplitterControl m_wndSplitter1;

Now, we create the control by calling it's create function. This code would
appear in the OnInitDialog or OnCreate function.

There is a tip here. Instead of calculating the rect for the splitter, we add
a static control on the dialog (by resource editor), give it an ID (IDC_SPLITTER1)
and make it invisible. Size it and locate in the resource editor, and then call
the function GetWindowRect(rc) to move the m_wndSplitter1 to the rect.

And here is the code for resizing controls on the dialog when the user moves
the splitter control.

Conclusion

Well, that's all about my code. Maybe, the explanation is not very clear, but
I hope you'll find it easy to use. No special skill, you see. Very simple. Thanks
for reading my article. Please give your ideas as to whether you like or hate it.

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.

Comments and Discussions

This is a good job,But I found a problem when I use it.
One dialog is Maximize,before it is restored.If I click the splitter and move down in this time,
it will move to the bottom of the dialog.And I could not move it up.
Could you tell me how to deal with the problem?
Thank you very much.