📄 scrolllabel.h
字号:
/*
* Copyright (c) 2002, Bcdliang
* All rights reserved.
*
* 文件名称:CSrollLabel.h
* 摘 要:类CSrollLabel的声明
* 类CSrollLabel实现了文字的上下、左右滚动,并可设定滚动效果、
* 文字的颜色和底色、字体、对齐方式、滚动的速度、步长等.
*
* 当前版本:1.01
* 作 者:LIANG Zheng
* 完成日期:2002年8月11日
*/
#if !defined(AFX_SCROLLLABEL_H__983A2E44_19D1_4B46_9CD4_2315575B890F__INCLUDED_)
#define AFX_SCROLLLABEL_H__983A2E44_19D1_4B46_9CD4_2315575B890F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CScrollLabel window
class CScrollLabel : public CWnd
{
// Construction
public:
CScrollLabel();
virtual ~CScrollLabel();
// Attributes
public:
//滚动效果
enum
{
SL_NONE = 0, //None
SL_HSCROLLLEFT = 1, //左滚动(完全消失才重现)
SL_HSCROLLRIGHT = 2, //右滚动(完全消失才重现)
SL_HSCROLLBOTH = 3, //左右来回滚动
SL_HSCROLLAUTO = 4, //左滚动(还剩1/3就重现)
SL_STYLENUM = 4, //已实现的滚动效果数(包括None)
SL_TA_LEFT = 0x0001, //Text Align: Left
SL_TA_RIGHT = 0x0002, //Text Align: Right
SL_TA_HCENTER = 0x0003, //Text Align: Horizon Center
SL_TA_TOP = 0x0010, //Text Align: Top
SL_TA_BOTTOM = 0x0020, //Text Align: Bottom
SL_TA_VCENTER = 0x0030 //Text Align: Vertical Center
};
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CScrollLabel)
protected:
//}}AFX_VIRTUAL
// Implementation
public:
void Default();
// 初始化数据成员
void Initialize();
// Get/Set:
// 设置/查询滚动效果
void SetScrollStyle(UINT nStyle);
UINT GetScrollStyle(void) const;
// 设置/查询字体
void SetFont(CFont *f);
CFont *GetFont(void);
// 设置/查询文字颜色
void SetTextColor(COLORREF crColor);
COLORREF GetTextColor() const;
// 设置/查询背景色
void SetBkColor(COLORREF crColor);
COLORREF GetBkColor(void) const;
// 设置/查询步长
void SetStep(UINT uStep);
UINT GetStep(void) const;
// 设置/查询速度
void SetTick(UINT uTick);
UINT GetTick(void) const;
// 设置/查询文字的水平对齐方式
void SetTextHAlign(UINT nStyle);
UINT GetTextHAlign(void) const;
// 设置/查询文字的垂直对齐方式
void SetTextVAlign(UINT nStyle);
UINT GetTextVAlign(void) const;
// 重写父类成员SetWindowText/GetWindowText
void SetWindowText(LPCTSTR lpszString);
void GetWindowText( CString& rString ) const;
// Generated message map functions
protected:
void CalculateTextSize(void); // 计算字符串的w,h, 并改变m_InnerRect的w,h, 但不改变其位置
CStatic m_InnerLabel; // 在Scroll Label内的, 真正显示文字的子窗口
CRect m_InnerRect; // Inner Label窗口的矩形
UINT m_uStep; // 步长:4(1-10)
UINT m_uTick; // 速度:200(50-2000)
UINT m_uScrollStyle; // 当前滚动效果
UINT m_uTextHAlign; // 当前文字的水平对齐方式
UINT m_uTextVAlign; // 当前文字的垂直对齐方式
COLORREF m_crBkColor, // 背景色
m_crTextColor; // 前景色
HBRUSH m_hBrush; // 背景刷子
CFont m_Font; // 当前字体
BOOL m_bLeft; // m_InnerLabel是否正在向左滚动(used in SL_SCROLLBOTH only)
//{{AFX_MSG(CScrollLabel)
afx_msg void OnTimer(UINT nIDEvent);
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SCROLLLABEL_H__983A2E44_19D1_4B46_9CD4_2315575B890F__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -