首页 > 编程语言 >WTL CBitmapHyperLink class

WTL CBitmapHyperLink class

时间:2022-12-13 14:47:17浏览次数:65  
标签:CBitmapHyperLink your link Link WTL class

WTL CBitmapHyperLink class

Image

Introduction

WTL has a CHyperLink class that is used to create hyperlinks. Main features of this control are:

  1. Hyperlink looks like the one in IE.
  2. While moving over the link, cursor becomes a hand.
  3. If cursor is kept over the link for a little while, a tooltip will appear.
  4. Class CHyperLink supports a keyboard interface as well.

But it does not allow to do two things that I was looking for - displaying a bitmap next to the link and changing link color when hover. So I've come up with the class CBitmapHyperLink that derives from CHyperLink and lets you do just this.

Using the code

To integrate CBitmapHyperLink into your app, you first need to add the following file to your project, like so:

 
#include <span class="code-string">"BitmapHyperLink.h"</span>

Then use the resource editor to add a static control to your dialog and define a variable in your dialog class:

 
CBitmapHyperLink m_Link;

Add the following lines in the OnInitDialog() function:

 
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, 
                       LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
    ...

    m_Link.SetHyperLink(_T("http://www.google.com"));
    m_Link.SetLabel(_T("Looking for something?"));
    m_Link.SubclassWindow(GetDlgItem(IDC_STATIC_URL));
    m_Link.SetExtendedStyle(HLINK_LEFTIMAGE | 
                   HLINK_UNDERLINEHOVER | HLINK_NOTOOLTIP);
    m_Link.SetLinkColor(RGB(0, 0, 0));
    m_Link.SetVisitedColor(RGB(0, 0, 0));
    m_Link.SetHoverColor(RGB(0, 0, 255));
    HBITMAP hBmp = m_Link.AddBitmap(IDB_BITMAP);
    ATLASSERT(hBmp);

    ...

    return TRUE;
}

History

标签:CBitmapHyperLink,your,link,Link,WTL,class
From: https://www.cnblogs.com/qzxff/p/16978703.html

相关文章