Being mostly curious, I was recently very interested in knowing more about Windows controls. After gathering various documentations and help from fellow developers in the ATL Mailing List, I decided to have a go.
The result of my tribulations was originally published in my now defunct article about a CaptionBar Windows Control, here at CodeProject. This article supersedes and enhances what was said at the time.
This article presents raw Win32 controls, as opposed to ActiveX controls. I'm providing wrapper classes for use in your WTL applications, and I expect people interested in these controls to provide MFC wrapper classes in the future.
I wrote these controls to satisfy my curiosity about Windows development in general, and because I felt there is space for UI improvement in the WTL arena. This control will come alongside others here at CodeProject to fill the gap.
Currently, version 1.2 of the springctrls.dll implements the following Windows controls:
How to use these controls
To use these controls, you need to include the springctrls.h header file and link your application with the springctl32.lib import library. The controls themselves are implemented in the springctl32.dll dynamic link library.
Before using any function involving the Windows controls, an application needs to register the various window classes using the
::InitWindowsControls() function. This function doesn't take any argument, and returns nonzero if it succeeds or zero otherwise.
The Win32 way
A Windows control is no more than a customized window, that respond to a specific set of messages. An application typically deal with a Windows control by using a bunch of
::SendMessage() calls to perform specific tasks.
Before an application can interact with a Windows control, the control window class must be registered, as described at the beginning of this section, and the control itself must be created using the
The WTL way
The code accompanying this article provides a set of wrapper classes, for use in your WTL applications. Using these wrappers is significantly easier than explicitly creating and sending appropriate messages to the controls.
The atlspctl.h header file contains the definitions of the Windows controls themselves. You can use methods of the
CCaptionBarCtrl classes as you would with any other common control wrapper classes provided in WTL.
The CaptionBar control needs more care for proper use. Like the standard
ReBar common controls, a
CaptionBar control positions itself at the top of its parent window's client area. Therefore, an application must manage the position and size of child windows in the remaining space. The atlspctlw.h header file provides an additional
CCaptionBarWindowImpl template to help you use this control efficiently.
The Spring Computing Windows controls
Shortcut controls act as containers for child windows. An application assigns child windows, which are often other controls, to a shortcut control pane. Shortcut controls contain one or more panes, and each pane can have a text label and a child window. Shortcut control panes cannot contain more than one child window.
A shortcut control has one pane currently displayed at any one time. As different panes are selected, the shortcut control manages the size and position of their child windows.
The following illustration shows a shortcut control with three panes:
CaptionBar controls are horizontal windows that position themselves at the top of a parent window's client area. A caption bar can display a combination of text and bitmap.
A caption bar control's caption text can be created as either being static, push button or toggle button.
The following animation shows a caption bar control that switches between static and toggle button mode, with an icon aligned on the right.
Although these controls were written from scratch, I have used information and sample code from various sources to help me.
This control greatly benefits from Tim Tabor's wonderful help. Tim is living on the outskirts of the ATL Mailing List and the WTL Mailing List, and was kind enough to answer some of my silly questions!
The Shortcut control was inspired by Christopher Brown's CWndSliderView as well as Rashid Thada's Outlook Bar Control and Frame.
I hope those controls will be useful. Certainly, writing them has been an exciting and wonderful challenge. I'm hoping to add more and more controls over time and welcome any suggestions. Of course, if you have written a piece of code that you would like to publish as Windows controls, we may turn this into a whole project, why not? And, please, feel free to give me any suggestions to enhance this article.