Introduction

This article is about a subclassed static control which you can use to scroll
hyperlinks from right to left. I once used it to scroll news headlines as
hyperlinks in an application.

Using the code

The source for this subclassed control is in ScrollLink.h and ScrollLink.cpp.
In it, you will find 2 classes, CScrollLink and CTextFrame.
The latter is used by CScrollLink for each hyperlink to scroll, so you don't
really need to know much about it to use this hyperlink scroller. To use it, you
need to use a Static control and subclassed with CScrollLink. Note that you need
to check the 'Notify' property of the static control.

The code listed below
will show you how to

Change the scrolling text colors, fonts, scroll speed, rate, etc.

Change the font attributes such as bold hyperlinks, underline them when
hovered.

CScrollLink::CScrollLink()
{
// Empty array
m_oTextFrames.RemoveAll();
m_iTextFramesScrolling.RemoveAll();
// Scroll rate is the value used in SetTimer(), which scrolls your hyperlinks to
// the left by x pixels, where x is the scroll speed value. Scroll allowance is the
// gap in pixels between 2 scrolling hyperlinks
m_uiScrollRate = SCROLLRATE;
m_uiScrollSpeed = SCROLLSPEED;
m_uiScrollAllowance = SCROLLALLOWANCE;
// The text of the hyperlink will be black if there is no url for it. If not, it will
// be blue. The color of the hyperlink is set to red when mouse it is hovered and the
// background color of the control is set to the same as the button color.
m_clrText = CLR_BLACK;
m_clrHover = CLR_RED;
m_clrBackground = GetSysColor(COLOR_BTNFACE);
// Set flag
m_bOnHover = FALSE;
}

2) Change the font attributes such as bold hyperlinks, underline them when
hovered.

This hyperlink scroller uses the same font as its parent. You can change its
font attributes for the scrolling text as well as when it is hovered in
CreateTextFonts as show below.

Now to add your hyperlink to the scroller, you should use AddScrollText as
shown below. Note that you can pass an empty url string and the scrolled text
will appear as a normal text instead of a hyperlink.

Points of Interest

Well, I need to apologize if my code comments appear vague. I am
still improving on that. Also, I know that some of my code could be further
improved, so I will be open to your comments, suggestions and criticisms.

License

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.