I don't like the standard ToolBars included in .NET, and the buttons have problems showing some details in 24-bit color bitmaps.
I looked around for a button I could use for making a "ToolBar" by just using a Panel and some buttons, but I did not find any that looked and acted the way I would like. That's why I started writing my own, and I think it came out pretty well, at least for my use.
One small note: I wrote this button fairly quickly and just forgot about everything while coding it. When I enter that state, I sometime forget to write comments, so there aren't a lot of comments in this code at the moment. I'll try to add some useful comments at a later time...
Whats so special about this button...
- It acts a bit like the toolbar buttons in VS .NET and Office 2003.
- It's flat, only draws a border and background when the mouse is over the button, and it can show both bitmaps and text.
- It can show the text either at the bottom or to the right of the bitmap, or just show the bitmap centered without any text.
- It's also able to show a ToolTip, as I wrote it for use in ToolBars.
I found the class called
ControlPaint in the .NET framework--this class can help with a lot of issues when writing controls. I use the
DrawImageDisabled() function to paint the bitmap on the button when it's disabled. That way the bitmap is shown as we are used to seeing a "disabled button" bitmap in other buttons.
The different properties
Rectangle: The button has the form a typical button--rectangular.
Ellipse: The button has an ellipse form, where the buttons region is actually set to the ellipse form so the mouse has to actually enter the ellipse to be able to click the button--it's not enough to click one of the "hidden corners" as it is with most rounded buttons.
Bottom: The text is showed centered on the button under the bitmap.
Right: The text is showed vertically centered to the right of the bitmap.
None: No text is showed and the bitmap is centered on the button.
HighLightColor: The color that fills the background of the button, when the mouse is over it.
OnlyShowBitmap: If this is set to true, no border, HighLightColor, or Text is ever painted, only the bitmap(s).
ToolTip: The ToolTip is displaye when the mouse hovers over the button.
NormalImage: The image that is shown when the button just sits "idle" and nothing is happening with it.
HottrackImage: The bitmap that is shown when the mouse enters the button. If this bitmap is null, the NormalImage bitmap is shown instead.
PressedImage: The bitmap that is shown when the user "clicks" on the button. If this bitmap is null, the NormalImage bitmap is shown instead.
2003-01-13 Version 1.0 released.