Click here to Skip to main content
Click here to Skip to main content
Go to top


, 19 Jul 2005
Rate this:
Please Sign up or sign in to vote.
A CButton derived class which gives you the ability to use hyperlink buttons in your application.

Sample Image - CHButton.jpg


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 to CHButton m_btn.
  • Compile and enjoy it Smile | :)


  • Version 1.3 (July 10, 2005)
    • Added SetIcon(..) function.
  • 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.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author


Other Other
No Biography provided

Comments and Discussions

GeneralgHi mOnO. Pinmemberdavid bagaturia17-Sep-07 20:07 
Generalmono Pinmemberbabaduli29-Nov-06 16:13 
GeneralNice PinmemberLevan Midodashvili13-Oct-05 13:01 
GeneralI don't see the point... PinmemberDouglas R. Keesler14-Jul-05 11:57 
General[Message Deleted] PinmemberGiorgi Moniava14-Jul-05 23:12 
GeneralRe: I don't see the point... PinmemberDouglas R. Keesler15-Jul-05 15:32 
GeneralRe: I don't see the point... PinmemberGiorgi Moniava15-Jul-05 22:52 
Douglas R. Keesler wrote:
If you were only trying to create a subclassed button with standard behaviors, but give it the appearance of "hyperlink" text, there is certainly nothing wrong with that --
That is what i wanted
Douglas R. Keesler wrote:
but both your article and your comments made it sound that you were creating some new and unique way of "hyperlinking" -- and that apparently isn't the case.
I have not mentioned anywhere that i was creating a unique way of Hyperlinking , i said that i needed such buttons and could not find them on the net. And it is true, all articles here about Hypelinks ,are Hyperlink controls which are not buttons they are objects of CStatic derived classes who only take you to specified URL-s.

Douglas R. Keesler wrote:
So again... what's the point? ... I guess if you want to open a dialog from a control that looks like hyperlink, then this is the class for you.. Right?? Do I understand you now?
Yes you do Smile | :)
And it is very handy sometimes to use such Hyperlink buttons in your application . For example Visual Studio.Net uses such buttons , for example in the Wizard when creating a simple MFC or another application.



"Success is the ability of going from one failure to another with no loss of enthusiasm" - W.Churchill

GeneralSearch PinmemberPJ Arends8-Jul-05 6:20 
GeneralRe: Search PinmemberGiorgi Moniava8-Jul-05 23:00 
GeneralRe: Search PinmemberDouglas R. Keesler15-Jul-05 19:45 
GeneralRe: Search PinmemberGiorgi Moniava15-Jul-05 22:56 
GeneralRe: Search PinmemberJames R. Twine25-Jul-05 4:58 
GeneralTwo Suggestion PinmemberThatsAlok8-Jul-05 2:41 
GeneralRe: Two Suggestion PinmemberGiorgi Moniava8-Jul-05 23:02 
GeneralNice! PinmemberThatsAlok8-Jul-05 2:12 
GeneralRe: Nice! PinsussAnonymous8-Jul-05 22:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140905.1 | Last Updated 20 Jul 2005
Article Copyright 2005 by ddmcr
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid