65.9K
CodeProject 正在变化。 阅读更多。
Home

具有滚动文本的静态控件

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.93/5 (9投票s)

2004年1月6日

viewsIcon

70838

downloadIcon

2127

CTextScroller 是一个智能控件,可以放置在“关于”对话框中。文本会自动格式化以适应客户端矩形。

引言

有一天,我正在开发一个大型应用程序,我一直在想在“关于”对话框中应该放些什么。我发现 2 或 3 句话是不够的,但我也知道对话框必须具有可接受的大小,那么解决方案是什么呢?我想到了一些可以显示长文本并且不占用太多空间的控件,因此 CTextScroller 就诞生了。

Sample Image - ScrollText.jpg

如何使用 CTextScroller

  • 在您的项目中包含 TextScroller.hTextScroller.cpp
  • 使用向导创建一个静态控件。您可以随意命名,但不要使用 IDC_STATIC,并为其添加一个成员变量。
  • 更改此成员的声明并进行设置
    CTextScroller m_Static;

一些有用的函数

void SetFontSize(int nSize);            //modify text font size
CString SetFontName(CString strFont);   //modify font name
void SetBorder(BOOL bSet=TRUE);         //draw ctrl borders
COLORREF SetTextColor(COLORREF color);  //modify text color
void SetScrollTimer(int nElapse);       //modify the speed of scroll
COLORREF SetBkColor(COLORREF color);    //modify background color
void AddLine(CStringArray &str);        //add text to the scroll
© . All rights reserved.