TabControl
The new SalQuickTabs control is based on the native TabControl component, which uses the tab control available in the standard Windows Common Controls module.
SalQuickTabs is a container hosting an instance of TabControl.
The inner control can be accessed using the public property TabControl. SalQuickTabs adds a number of improvements to the standard tab control in order to support converted applications.
Added features
Binding to multiple pages
The native TabControl cannot bind the same control to more than one tab page. This is supported in the SalQuickTabs control and it's a fairly common feature found in original Team Developer applications.
Binding to sibling controls
The native control binds only to child controls hosted inside the TabPage. Ported code, however, expected the controls bound to the tabs control to be sibling controls, which also makes it possible for the bound controls to be outside of the tabs control. This is another commonly used feature in Team Developer applications.
In some cases, we have also found tab control used as hidden control to show/hide collections of controls on the form.
Because the SalQuickTabs control binds sibling controls and not children controls, the z-order of the bound controls relative to the SalQuickTabs control is very important because the bound control must be above the tabs control. For this reason, by default, the tabs control will always and automatically go to the bottom of the z-order when the form is loaded.
Binding to forms
In many instances, Team Developer applications using the TabControl put the controls in a form and then bind the entire form. The same form may be used in other parts of the application as well. This feature is also supported.
Mnemonics support
The SalQuickTabs control supports tab labels with mnemonics, while the native TabControl doesn't.
Mnemonics are not displayed when the XP style is on because you cannot owner draw the tabs.
Disabled tab pages
The native TabControl doesn't support disabled pages. SalQuickTabs supports disabled tabs.
The tab label for disabled tabs is not drawn disabled when Visual Styles mode is turned on.
Tabs Control Editors
Tab pages in the SalQuickTabs control can be edited using the TabSetup property.
This is a string property that contains the description of the tab pages and can be edited by hand or by using the built-in designer shown in the images below:
You can edit the string directly or use the designer shown in the image below.
The TabSetup string defines the tab pages configuration using groups of properties delimited by curly brackets and separated by a semicolon.
For example:
{Name=TabName;Label=TabLabel;Form=BoundFormName;BackColor=ColorCodeOrName; ForeColor=ColorCodeOrName; VisualStyle=True|False}.
To bind a control to a tab page you have to set the "ControlTabPages on picTabs" extender property.
It is a simple string property that contains the names of the tabs that the control is bound to, separated by a comma. You can edit the property directly or you can use the built-in editor shown below:
Visual Styles Support
When the application is running with Visual Styles turned on, the TabControl's background is painted using a gradient brush and this doesn't fit well with .NET's non-transparent controls.
In fact, it is common in older .NET applications to draw the tab page using the normal background for controls instead of the Visual Style background.
Using the SalQuickTabs control it is possible to enable Visual Styles support for a single tab page or for the entire tabs collection. For a single page you can set the VisualStyles property to true in the TabSetup string. For the entire control, you can simply set the property UseVisualStyleBackColor to true.
Since .NET controls cannot have a transparent background, the controls bound to the tabs control will still paint their solid background over the tab page.
Therefore, once the Visual Styles mode has been enabled, you also have to set the BackColor of the bound controls that need to appear transparent to Transparent. This is not really transparent though, it simply means that the parent will paint the background.
The parent of controls bound to a SalQuickTabs control is the form and not the TabControl. Therefore the background would be painted by the form which has no knowledge of the special visual style rendering used to paint the background of tab pages.
In the PPJ Framework we have added an interface ISalTransparentControl to expose the PaintBackground event (which is missing from the .NET Framework). SalQuickTabs takes over painting the background of controls implementing ISalTransparentControl by attaching to the PaintBackground event.
Custom Drawing
SalQuickTabs also supports two kinds of custom drawing by exposing two events: DrawItem and DrawControl.
The DrawItem event is fired when the tab control needs to draw the tab part of the tab page and it's supported only when Visual Style are turned off because Windows doesn't support owner drawn tab controls with Visual Styles.
The DrawControl event is fired always and allows for full custom painting of the entire tab control.
Last updated