用paint()函数实现在对话框中显示滚动字幕!
来源:互联网 发布:数据结构与算法怎么学 编辑:程序博客网 时间:2024/06/02 20:33
//在对话框头文件中定义
CString str;
int WidthX;//输出文本的水平位置
TEXTMETRIC tm;//字体结构
//在购造函数中赋初值
CScrollTextDlg::CScrollTextDlg(CWnd* pParent /*=NULL*/)
: CDialog(CScrollTextDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CScrollTextDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
str="欢迎学习使用VISUAL C++!";
WidthX=100;
}
//在初始化中定义时间器
SetTimer(1,150,NULL);//设定定时器
void CScrollTextDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
rect.top=45;
rect.bottom=rect.top+tm.tmHeight+10;
rect.left=WidthX-10;
rect.right=rect.left+str.GetLength()*tm.tmAveCharWidth+20;
InvalidateRect(&rect);
CRect rect2;
GetClientRect(&rect2); //获取对话框客户端大小
if(WidthX<-str.GetLength()*tm.tmAveCharWidth) //判断是否到了最左边
{
WidthX=rect2.right;
}
WidthX=WidthX-6;
UpdateWindow();
CDialog::OnTimer(nIDEvent);
}
//在onpaint()函数中实现字幕显示
else
{
// CDialog::OnPaint();
CPaintDC dc(this);
dc.SetTextColor(RGB(18,0,210));
dc.SetBkMode(TRANSPARENT);
dc.TextOut(WidthX,45,str);
dc.GetTextMetrics(&tm);//获取字体结构
}
- 用paint()函数实现在对话框中显示滚动字幕!
- MFC——在状态栏中显示滚动字幕
- QT 实现在ui控件QLabel中实现滚动字幕
- 状态栏显示滚动字幕
- 用js实现字幕滚动效果.
- Winform实现滚动字幕
- Winform实现滚动字幕
- Android 滚动字幕实现
- Java实现滚动字幕
- Android 滚动字幕实现
- Android 滚动字幕实现
- MFC滚动字幕实现
- Qt实现滚动字幕
- premiere 实现字幕在指定框内滚动
- iOS中UILabel滚动字幕动画的实现
- iOS中UILabel滚动字幕动画的实现
- iOS中UILabel滚动字幕动画的实现
- 如何实现EDIUS中滚动字幕的制作
- DWR的替代品Ext.Direct
- [轉]Delphi 中串口通信的實現
- 正则表达式
- c# mvc 中 View 界面的值如何通过 Model 传到 Controller
- 编程过程中Notice: Use of undefined constant XXXX和Warning:expects parameter 1 to be resource...
- 用paint()函数实现在对话框中显示滚动字幕!
- Oracle 中实现随机抽取数据
- 超分辨率
- Oracle 中实现随机抽取数据
- Oracle 中实现随机抽取数据
- 用axis实现webService--服务端+客户端
- VC 基本操作
- MSSQL、MYSQL,ACCESSl,Oracle随机读取N条记录方法
- 多线程