AR Flat Button
ActiveX Control 1.06 |
This is just another flat button control,
that admits either a picture or a caption. It also has extra functionallity that will
allow you to set certain aspects of the behaviour of the control, like different pictures
depending on the state, if the button should popup or if the button should stay pressed on
a click.
THIS CONTROL HAS
BEEN REPLACED AND IMPROVED BY THE AR Button Control.
I didn't think about doing a control like
this, as I have the Sheridan ActiveThreed Controls,
which allow me to do most of the typical visual effects to my programs. They are quite
expensive, though. There is also a 'Soft Button' control in the VB Owners section of the Microsoft Visual Basic web site, although this
control only works with graphics, and doesn't allow you to have a button just with a
caption (it also has a couple of bugs, but don't tell Microsoft). Finally I have seen
other controls but they didn't work very well, and most of them were almost exact copies
of the control made by Microsoft.
Anyways, as many people asked me about
controls of this kind, and I also wanted to have a couple of features missing in other
controls, I made my own one.
This control uses the Hot Track library,
made by some programmer in Microsoft and
distributed from the VB
Owners web site. This library provides my control of the necessary events to handle
the position of the mouse. The source code of the library is compiled with the control for
speed.
Remember that to be able to use the
control you will have to introduce the license information in the registry of your
computer. You can do this by just double clicking on the 'AR Flat Button Control
License.reg' file, included in the ZIP.
The control has a lot of properties,
methods and events, so I will just comment the ones specific for this control. If you find
any bugs, you have comments, or you think I should add something to this control, please contact me.
History:
- 19.03.98: Released version 1.0.
- 21.03.98, Version 1.01: Added
functionallity (properties 'DarkEdges' and 'Active'), fixed a bug with the ToolTipText
(also removed the 'ToolTipTxt' property), improved the appearance of the control in other
aspects.
- 22.03.98, Version 1.02: The control will
be able to show up to four different pictures depending on the state, through the
following properties: DisabledPicture, OnPicture, PressedPicture, Picture. Also added the
'Enabled' property, that will show a different picture on the button if it is set, and
will make the button not respond on any events.
- 08.04.98, Version 1.03: this release just
improves the behaviour of the control.
- 12.04.98, Version 1.04: Added the
possibility of aligning the text in the caption (left, right and center) using the
alignment property. Also improved some aspects of the control. Fixed a bug involved with
the 'StayPressed' property (read the Considerations section).
- 12.05.98, Version 1.05: Fixed a couple of
minor bugs. Added the 'SetState' method.
- 08.06.98, Version 1.06: Fixed a bug that
made the control not work properly when was disabled from its own code.
Properties:
- Active. When set to false, the button will
not popup when the mouse is over it, but it will still get inset when clicked.
- Alignment. Left, Right or Center; this
property sets the alignment of the text shown in the caption when the button is in text
mode.
- AutoSize. If true, the control will adjust
its size to the size of the text or graphic that contains.
- BackColor. BackColor for the control.
- Caption. That, the text that will be
shown.
- DarkEdges. When true, the thin shadow of
the control will be darker. Depending on the color of the form over which the control is,
this might look better.
- DisabledPicture. Picture that will be
shown when the control is disabled.
- Enabled. When true, the button will not
respond to any events. Also, if the style is 'Graphic' and the 'DisabledPicture' property
is set, the button will show the graphic set in the 'DisabledPicture' property.
- Font. Font that will be used to show the
caption.
- ForeColor. Color used to show the caption.
Ignored when displaying a picture.
- OnPicture. Picture that will be shown when
the mouse is over the control.
- Picture. Graphic that will be shown in the
button.
- PressedPicture. Picture that will be shown
when the button is pressed.
- StayPressed. When true, one click to press
the button and another to release. If false, you press and release the button with only
one click.
- Style. 'Graphic' or 'Text'. If 'Graphic',
the caption is ignored; when 'Text' the picture is ignored. If there is no picture set,
the button stays in 'Text' mode.
- ToolTipTxt. THIS PROPERTY IS NO LONGER
VALID, although it still exists for compatibility. Instead, use the normal 'ToolTipText'.
Methods:
- SetState (lState as enState). lState can
be Flat (0), Raise (1) or Pressed (2). Use this method to, programmatically, set the state
of the button.
Events:
- Click ()
- MouseEnter ()
- MouseLeave ()
Considerations:
- If the control is the first one in the tab
stop list, and 'StayPressed' is true, when the form loads the control will appear pressed.
To avoid this, set 'TabStop' to false or put another control with a lower 'TabIndex'
property.
- If you want to put a transparent picture,
you can put a transparent icon or a transparent GIF. The transparent part of the image
will be set to the background color of the control. This is easier and works better than
dealing with the 'MaskColor' property, so I didn't include it in this control.
- If you are using different pictures for
different states, make sure that all the pictures are the same size. Otherwise the control
will have a strange behaviour.
- If you don't set the 'DisabledPicture',
'OnPicture' or 'PressedPicture' properties, the control will use the picture set in the
'Picture' property. If you don't set this last one, the control will automatically change
its style to 'Text'.
- If you don't want the control to popup,
but you still want its picture to change when the mouse is over it, use the 'MouseEnter'
and 'MouseLeave' events with the 'Picture' property.
- Before version 1.04, if the button had the
'StayPressed' property set to true and you clicked on any other part of the form
(including other controls), the button appeared as released. Depending on how you want to
use the control, this may be correct or wrong. From now on, to make the button stay
pressed set its 'TabStop' property to false.
|
(48 Kb) |
© Alvaro Redondo, 1998. All Rights Reserved.
http://www.sevillaonline.com/ActiveX/