TOffice97Button ReadMe
By Jonathan Hosking
V1.9 (1/3/2000)

Table of Contents

What is the TOffice97Button Component?
How to install the TOffice97Button component
TOffice97Button Reference
Revision History
Future Ideas
Other Components
Contacting Me

What is the TOffice97Button component?

The TOffice97Button component is a new component I have written for Delphi and C++Builder. It looks and acts like the controls (Buttons, radiobuttons, up buttons and down buttons) that appear in the Office Assistant balloons in Office 97 and Office 2000. It can be fully customised if desired. It has the following features: -

The component code was written by modifying some code for an Internet Explorer-style button, written by Dave Jewell. Code from the TButton component was also used to write some handling routines and the code for creating a disabled bitmap was taken from the RX Library v2.40. The code works fine on Delphi 1.0, 2.0, 4.0, 5.0 and C++Builder 3.0, but I have not tested it with other versions.

You are free to distribute the code, but you may NOT sell it. If you modify the code, you must include me in the acknowledgements. If you do want your ideas or modifications to be incorporated into the latest version, send them to the address at the end of this document.

Thanks to Kambiz for adding bi-directional support and for the auto height adjustment routines.

How to install the TOffice97Button component

To unzip the TOffice97Button component, assuming [Program Path] is the path to Delphi or C++Builder, follow these steps: -

  1. Unzip the file OFFBTN97.ZIP to any directory, using the directory switch (This is VERY important).
  2. Copy the file OFFBTN.PAS to the directory [Program Path]\Source\Samples.
  3. If you want documentation, copy the file OFFBTN97.HTM to the directory [Program Path]\Bin, if you are using Delphi 1.0. Otherwise, copy it to the directory [Program Path]\Help.
  4. If you are using Delphi 1.0, copy the files in the 16-Bit directory of this Zip to the directory [Program Path]\Source\Samples. Otherwise copy the files in the 32-Bit directory of this Zip to the directory [Program Path]\Source\Samples.

You can now install the component into the component library. Ignore the 3 compiler warnings about variables not being initialised. Follow the procedure for the version of Delphi or C++Builder that you are using.

Delphi 1.0:

  1. Click on Options and then select Install Components.
  2. In the Install Components dialog, click Add. In the next dialog, click Browse and open the file OFFBTN.PAS.
  3. Click Ok to install the component.

Delphi 2.0:

This procedure should also work with C++Builder 1.0, but I'm not sure.

  1. Click on Component and select Install.
  2. In the Install Components dialog, click Add. In the next dialog, click Browse and open the file OFFBTN.PAS.
  3. Click Ok to install the component.

Delphi 4.0:

  1. Click on Tools and select Environment Options.
  2. In the next dialog, click on the Library tab and add the full path of the TOffice97Button source code to the Library Path edit box. Then click Ok.
  3. Click on Component and select Install Component.
  4. In the Install Component dialog, click on the Into existing package tab. Click on the first Browse button and open the file OFFBTN.PAS. Then click on the second Browse button and open the file DCLUSR40.DPK. Finally, click Ok to install the component.

Delphi 5.0:

  1. Click on Tools and select Environment Options.
  2. In the next dialog, click on the Library tab and add the full path of the TOffice97Button source code to the Library Path edit box. Then click Ok.
  3. Click on Component and select Install Component.
  4. In the Install Component dialog, click on the Into existing package tab. Click on the first Browse button and open the file OFFBTN.PAS. Then click on the second Browse button and open the file DCLUSR50.DPK. Finally, click Ok to install the component.

C++Builder 3.0:

This procedure should also work, with minor modifications, with Delphi 3.0 and C++Builder 4.0, but I'm not sure.

  1. Click on Tools and select Environment Options.
  2. In the next dialog, click on the Library tab and add the full path of the TOffice97Button source code to the Library Path edit box. Then click Ok.
  3. Click on Component and select Install Component.
  4. In the Install Component dialog, click on the Into existing package tab. Click on the first Browse button and open the file OFFBTN.PAS. Then click on the second Browse button and open the file DCLUSR35.BPK. Finally, click Ok to install the component.

TOffice97Button Reference

Remarks:

You may wonder why 2 resource files are used with this component. There are several explanations for this: -

  1. The DCR file could not be linked in, because doing so would cause a "Duplicate Resource Identifier" error.
  2. The bitmaps in the RES file have to be linked in, otherwise they won't display properly. They can't be in the DCR file, as this would mean linking the DCR file, which would cause the error described above.
  3. A RES file can't be used alone, as the error described above would occur and the component's icon would not be displayed.

The bitmaps used to indicate the status of the control can be edited by opening the file OFFBTN.RES. These bitmaps are the default bitmaps for every TOffice97Button component, so any changes will be global. The bitmaps are stored in the following names: -

The assumed transparent colour of the bitmaps is clBlack. This can be changed by modifying the fTransparentColor variable in the TOffice97Button.Create(AOwner: TComponent) constructor, or by modifying the TransparentColor property.

It is not advisable to reduce the control size. If you do, the control may not display exactly as it should. Text may disappear if the control becomes too small. There shouldn't be any fatal errors if the control size is decreased. You also should not delete any of the bitmaps, or rename them, as this will probably cause errors.

When the ControlType property is set to anything other than bsButton, the control frame is not drawn and the focus is drawn in the Office 97 style. It is also a fixed size when text is word-wrapped, unless you change the control size.

Early versions of the component used the cmFocusChanged message to handle focus control. This was eventually replaced by the wmKillFocus and wmLostFocus messages in version 1.4, fixing a very annoying bug. However, the cmFocusChanged message is still called, to update the control, when the Default property is set.

If you are upgrading the component to version 1.9 or later of the control, you may find that the glyphs on any TOffice97Buttons disappear. If this happens, toggle the Office2000Look property on and off.

Known Problems:

There are currently no problems with the control.

Key Properties:

Key Events:

Revision History

V1.9 (1/2/2000)

V1.82 (22/12/1999)

V1.81 (21/11/1999)

V1.8 (30/10/1999)

V1.7 (04/09/1999)

V1.69 (17/08/1999)

V1.68 (12/08/1999)

V1.67 (25/05/1999)

V1.66 (16/03/1999)

V1.65 (19/02/1999)

V1.64 (22/01/1999)

V1.63 (09/12/1998)

V1.62 (30/08/1998)

V1.61 (05/05/1998)

V1.6 (26/02/1998)

V1.5 (08/02/1998)

V1.4 (01/02/1998)

V1.3 (27/01/1998)

V1.2 (26/01/1998)

V1.1 (01/01/1998)

V1.01 (10/12/1997)

V1.0 (09/12/1997)

Future Ideas

I currently only have one idea for future versions of the TOffice97Button component. It is listed below: -

Other Components

Below is a list other components that I have written: -

Contacting Me

I am currently on the Internet. If you have any bug reports, comments, ideas, modifications, etc. then you can Email me at the address given below. You can also go to my web site to find out the latest information on my components.

Email: - jonathan@the-hoskings.freeserve.co.uk
WWW: http://www.the-hoskings.freeserve.co.uk/