Menu

Replacing_usage_of_BWCC

Replacing the Borland Windows Custom Controls (BWCC)

OWLNext 6.30 is the last version that supports usage of BWCC. Since version 6.32 it is no longer available, and the function TApplication::EnableBWCC has been removed. Legacy applications that still make use of BWCC will have to be converted to use the standard dialog controls instead. TGlyphButton can be used to put icons on buttons.



What is BWCC?

BWCC stands for Borland Windows Custom Controls. It is a library developed by Borland to give controls a nicer 3D look for applications running on Windows 3. Borland C++ 4 made use of it, but with the coming of Windows 95, which introduced it's own 3D look, BWCC became outdated. As a replacement, OWL 5 introduced TGlyphButton for adding icons to buttons.


Converting BWCC dialogs

There are several steps that must be taken to remove the usage of BWCC in a legacy OWL application:

  • Remove calls to TApplication::EnableBWCC.
  • Remove the "BorDlg" or "BorDlg_Gray" class from dialog resources.
  • Replace the BWCC control classes by standard Windows classes.
  • Correct the dialog look-and-feel, editing controls as needed.
  • Optionally, use TGlyphButton in the dialog class to have similar buttons with icons.



An example of BWCC dialog conversion

This example illustrates the steps needed to convert a simple BWCC dialog to the native style.


The original BWCC dialog created with Borland C++ 5.02

Code for the dialog resource:

 IDD_CLIENT DIALOG 6, 15, 189, 124
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
 CLASS "BorDlg_Gray"
 CAPTION "Dialog Client"
 FONT 8, "MS Sans Serif"
 BEGIN
   CONTROL "Project file type", -1, "BorShade", BSS_GROUP | BSS_CAPTION | BSS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 8, 128, 48
   CONTROL ".&RC", 151, "BorRadio", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 12, 21, 33, 12
   CONTROL ".RE&S", 154, "BorRadio", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 12, 37, 33, 12
   CONTROL ".&CUR", 158, "BorRadio", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 54, 21, 33, 12
   CONTROL ".&ICO", 159, "BorRadio", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 55, 37, 33, 12
   CONTROL ".&BMP", 160, "BorRadio", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 99, 21, 33, 12
   CONTROL ".&FNT", 162, "BorRadio", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 98, 37, 33, 12
   CONTROL "", -1, "BorShade", BSS_HDIP | BSS_LEFT | WS_CHILD | WS_VISIBLE, 0, 64, 144, 2
   CONTROL "", 1, "BorBtn", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 8, 74, 37, 25
   CONTROL "", 2, "BorBtn", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 74, 37, 25
   CONTROL "", 998, "BorBtn", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 98, 74, 37, 25
 END

Here is how the dialog looks:


Removing BWCC dialog and control classes

The first step is to remove the BWCC classes. The line CLASS "BorDlg_Gray" is removed from the dialog resource, and the control classes are replaced with Windows analogues (which is "Button" in most cases):

 IDD_CLIENT DIALOG 6, 15, 189, 124
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
 CAPTION "Dialog Client"
 FONT 8, "MS Sans Serif"
 BEGIN
   CONTROL "Project file type", -1, "Button", BSS_GROUP | BSS_CAPTION | BSS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 8, 128, 48
   CONTROL ".&RC", 151, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 12, 21, 33, 12
   CONTROL ".RE&S", 154, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 12, 37, 33, 12
   CONTROL ".&CUR", 158, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 54, 21, 33, 12
   CONTROL ".&ICO", 159, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 55, 37, 33, 12
   CONTROL ".&BMP", 160, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 99, 21, 33, 12
   CONTROL ".&FNT", 162, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 98, 37, 33, 12
   CONTROL "", -1, "Button", BSS_HDIP | BSS_LEFT | WS_CHILD | WS_VISIBLE, 0, 64, 144, 2
   CONTROL "", 1, "Button", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 8, 74, 37, 25
   CONTROL "", 2, "Button", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 74, 37, 25
   CONTROL "", 998, "Button", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 98, 74, 37, 25
 END

Unfortunately, after recompiling, the dialog looks pretty awful:


Correcting dialog controls

There are two obvious problems: (1) the group box caption has moved to the center, underneath the radio buttons, and (2) the push buttons are empty. To fix the group box, add the style BS_GROUPBOX and remove the BSS_* styles, which are BWCC-specific. To fix the second issue, add captions to the buttons:

 CONTROL "Project file type", -1, "Button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 8, 128, 48
 CONTROL ".&RC", 151, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 12, 21, 33, 12
 CONTROL ".RE&S", 154, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 12, 37, 33, 12
 CONTROL ".&CUR", 158, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 54, 21, 33, 12
 CONTROL ".&ICO", 159, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 55, 37, 33, 12
 CONTROL ".&BMP", 160, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 99, 21, 33, 12
 CONTROL ".&FNT", 162, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 98, 37, 33, 12
 CONTROL "", -1, "Button", BSS_HDIP | BSS_LEFT | WS_CHILD | WS_VISIBLE, 0, 64, 144, 2
 CONTROL "OK", 1, "Button", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 8, 74, 37, 25
 CONTROL "Cancel", 2, "Button", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 74, 37, 25
 CONTROL "Help", 998, "Button", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 98, 74, 37, 25

The dialog now looks better:


Adding icons to the buttons

Use the TGlyphButton class to add icons to the dialog buttons.

  • Add the line #include <owl/glyphbtn.rc> in the beginning of the resource file. This is required if linking with the static versions of OWLNext libraries.
  • In the dialog class, add TGlyphButton instances for the buttons. If there are already TButton members used to manipulate the buttons, replace them with TGlyphButton. If not, then simply create the new objects in the dialog constructor, without keeping them in member variables.

For example:

 TBWCCTestDlgClient::TBWCCTestDlgClient(TWindow* parent, TResId resId, TModule* module) : TDialog(parent, resId, module)
 {
   new TGlyphButton(this, 1, TGlyphButton::btOk);
   new TGlyphButton(this, 2, TGlyphButton::btCancel);
   new TGlyphButton(this, 998, TGlyphButton::btHelp);
 }

Now the buttons will have icons:


Further steps

An additional step may be to redesign the look of the dialog for a more modern style. For instance, the height of the buttons should ideally be reduced, and controls may need to be rearranged for better spacing and layout.

You may also want to enable themes; the visual styles introduced in Windows XP. Otherwise, the Windows controls are rendered in the classic Windows 95 style (as shown in the screenshots in this article). See "How do I enable visual styles (themes) in my application" in the FAQ. Also, see the example XPThemes in the OWLNext installation. Support for themed glyph buttons was added in OWLNext 6.34. See "How do I get themed rendering of TGlyphButton" in the FAQ.


Related

Discussion: _T(BWCC_CLASSNAME) required
Discussion: OWL_Slider WndProc
Discussion: How to change the font of a TDialog
Feature Requests: #75
Wiki: Knowledge_Base
Wiki: Upgrading_from_OWL

MongoDB Logo MongoDB