CHButton
Introduction
The idea was simple, I needed to use simple hyperlink buttons in my application. I searched for them on the net and could not find any, so I decided to write down my own class of Hyperlink buttons. CHButton
is a CButton
derived class and its objects are simple buttons, with the user interface of a Hyperlink control. The only thing you'll have to do is to attach a cursor to it, which you can do using the function:
void SetCursor(BOOL HCURSOR m_Cursor);
Sets cursor of the Hyperlink button.
This class also has the following public methods:
void SetUnderline(UINT nUnderline);
Sets the chosen Underline state to the button.
nUnderline
can have the following values:
HS_ALWAYS
- Displays the underline always.HS_HOVER
- Displays the underline when the mouse is over the button.HS_NONE
- Removes the underline if exists.
void SetHoverTextColor(COLORREF clrTextColor,BOOL bShowColor =TRUE);
Sets the Hyperlink button text color when the mouse is over the button.
void SetTextColor(COLORREF clrColor)
Sets the text color of the Hyperlink button.
void SetIcon(HICON Icon)
Sets the specified icon to the button.
void SetToolTip(LPCSTR strText, BOOL bActive = TRUE);
Sets the ToolTip text for the Hyperlink button.
How to Use it
- Add "HButton.cpp" and "HButton.h" files to your project.
- In your dialog's header file, write:
#include "HButton.h"
. - Create a button on your dialog and in the Properties tab set the "owner draw" property.
- Add a
CButton
m_btn
variable to the just created button and in your dialog's header file rename it toCHButton m_btn
. - Compile and enjoy it :)
History
- Version 1.3 (July 10, 2005)
- Added
SetIcon(..)
function.
- Added
- Version 1.2 (July 10, 2005)
- Added Hover Underline feature.
- Version 1.1 (July 08, 2005)
- Posted on CodeProject.
- Version 1.1 (July 06,2005)
- Added Tooltip support.
- Version 1.00 (July 05, 2005)
- Initial release.