| home
Part III Introduction Ernest Murphy ernie@surfree.com October 18, 2000 Get the source code
here.
Abstract:
Splitter bars are a distinctive visual control element that help organize a large amount of information in a window. They allow your user to resize the relation between two panes of information. A very common example of a splitter is in Windows File Explorer, which uses a splitter bar to divide two panes of information. Having built a reusable library to
hold our splitter bar class, we now demonstrate a program that uses the
splitter.
Introduction:
If the code for the program in this part looks somewhat familiar, good for you. You have recognized Iczelion's Tutorial 10: Dialog Box as Main Window. I copied most of his source (and most of the resource code too) as a base for this project. The first change I made was to the dialog resource. The buttons were removed, a second edit control was added, and the menu was simplified. The final window looks like so: Wow, see it there in the middle? That's
our splitter. First, let's look at the resource file:
Look closely at the middle line in the DIALOG BEGIN block. See the CONTROL statement? That is our splitter control. The CONTROL statement is a generic way to load a control that rc.exe (the resource compiler) does not understand. The CONTROL statement will translate
to the following code:
where cxChar and cyChar are the width and height of a system font character in pixels. We only need make a slight addition
to the program between the lines where we CreateDialogParam and ShowWindow:
These are our new window messages. We use GetDlgItem to get the window handle of the three controls on our parent window, and use the splitter window handle to send a message to our splitter what the side window handles are. Then we send the minimum widths. For this test program, we make the left side noticeably wider then the right side. Now, compile the program and run it. That's all we need do to get our new custom control to run in our project. Gee, that was easy, huh? ------------------------------------------------------------------------------------------ |