Class TGradButton (unit Gradbtn) |
TSpeedButton
Graduated-Color Fill Button Component John Baumbach Delphi 1.0 or 2.0 email: mantis@vcnet.com 1-2-96 http://www.vcnet.com/mantis Also check out: TMovingButton: button that travels around in the parent container or form ScrollingBackground: Form Gallery Component that has a background that scrolls smoothly down the form (behind the components...) Available on my home page (see above). Installation Instructions: To check out a sample application without installing the component, load the project file "grad.dpr" with the Delphi editor and run. If you have an error like "Can't execute a DLL", make sure the sample form is loaded by "View | Forms | GradTest", then clicking "OK". If you have an error like "Invalid File Name" during compile time change your "Options | Project | Directories-Conditionals | Output Directory" to blanks (if Delphi is set up to produce an output file). Installing Component to Toolbar: This component is currently set up to be added to the "Samples" palette of the toolbar. If you wish to add it to a different one, change the word "Samples" to the name of the desired palette in the "Register" procedure below. Select "Options | Install Components" and select "Add", then "gradbtn.pas" from the directory where you unzipped this file. Delphi will then recompile the toolbar and the "TGradButton" component will be added to the palette! If you want to keep this component permanently, copy the "gradbtn.pas" and "gradbtn.dcr" files to the "Delphi\LIB" subdirectory and follow the above installation step. You can remove the component at any time the same way, except choose "Options | Install Components" and choose "GradButton" to remove. The icon for this component is in the file "gradbtn.dcr". If you use this component under Delphi 2.0, load it into the resource editor and then save it. Otherwise, Delphi won't be able to compile it correctly. Using the GradButton: Once installed in toolbar, you can use it just like it's ancestor, the "TSpeedButton" component. However, there are a few new features and properties that you can set. The new properties are: BevelWidth width in pixels of the button's bevel BorderWidth the black background width around the button FaceColor the top graduated color of the button GradColor the bottom graduated color of the button HighlightColor the highlight color of the bevel ShadowColor the shadow color of the bevel Limitations: Glyph: The "Glyph" property of the button doesn't work. You can add it yourself in the "Paint" routine if you wish. Hot Key: You can't use a hot key with the button (ie. "&OK") Colors: If you are using a 16 or 256 color system, I would recommend using only dark colors for the graduated fill and keeping the button size small. This is to keep the dithering effect down to a minimum. On systems with more colors (32K+), the graduated color effect looks fantastic on any size button or with any colors.
Constructors |
Create the button
Functions |
This procedure draws the button onto the form
This procedure draws the gradient colors onto the bitmap
Properties |
Events |
Variables |
Constructors |
Public Declarations
Create the button
Functions |
Draw the gradient colors to the background bitmap for future painting
Protected Declarations
This procedure draws the button onto the form
1
This procedure draws the gradient colors onto the bitmap
The "Set..." procedures redraw the button after a property is changed
Properties |
Published Declarations
Events |
Variables |
Private Declarations
clBlack
clWhite
clBlue
clBlack
1