一个从右到左,文字循环平滑滚动的例子(Delphi7测试通过)
2008-05-15 15:12
706 查看
procedure TForm2.Button1Click(Sender: TObject);
var
oldRect, rzPanelRect: TRect;
oldBitmap: TBitmap;
position, I, TxtWidth, CWidth, iPosition: Integer;
fText: string;
pWidth, pHeight: integer;
begin
{
一个从右到左,文字循环平滑滚动的例子。
2008-05-15。by Heavy.
}
position := 0;
iPosition := 0;
fText := '战胜灾难,众志成城!';
pWidth := RzPanel1.Width;
pHeight := RzPanel1.Height;
oldBitmap := TBitmap.Create;
oldBitmap.Width := pWidth;
oldBitmap.Height := pHeight;
oldBitmap.Canvas.Brush.Color := clActiveCaption;
//填充背景色
oldBitmap.Canvas.FillRect(Rect(0,0,oldBitmap.Width,oldBitmap.Height));
oldBitmap.Canvas.Font.Color := clWhite;
oldBitmap.Canvas.Font.Size := 14;
oldBitmap.Canvas.TextOut(0, 10, fText);
TxtWidth := oldBitmap.Canvas.TextWidth(fText);
while Position >= -pWidth - TxtWidth do
begin
if Position <= -pWidth then
RzPanel1.Canvas.Draw(2 * pWidth + Position, 0, oldBitmap);
RzPanel1.Canvas.Draw(pWidth + Position, 0, oldBitmap);
sleep(50);
Application.ProcessMessages;
if Position = -pWidth - TxtWidth then
Position := -TxtWidth;
Dec(Position);
end;
end;
var
oldRect, rzPanelRect: TRect;
oldBitmap: TBitmap;
position, I, TxtWidth, CWidth, iPosition: Integer;
fText: string;
pWidth, pHeight: integer;
begin
{
一个从右到左,文字循环平滑滚动的例子。
2008-05-15。by Heavy.
}
position := 0;
iPosition := 0;
fText := '战胜灾难,众志成城!';
pWidth := RzPanel1.Width;
pHeight := RzPanel1.Height;
oldBitmap := TBitmap.Create;
oldBitmap.Width := pWidth;
oldBitmap.Height := pHeight;
oldBitmap.Canvas.Brush.Color := clActiveCaption;
//填充背景色
oldBitmap.Canvas.FillRect(Rect(0,0,oldBitmap.Width,oldBitmap.Height));
oldBitmap.Canvas.Font.Color := clWhite;
oldBitmap.Canvas.Font.Size := 14;
oldBitmap.Canvas.TextOut(0, 10, fText);
TxtWidth := oldBitmap.Canvas.TextWidth(fText);
while Position >= -pWidth - TxtWidth do
begin
if Position <= -pWidth then
RzPanel1.Canvas.Draw(2 * pWidth + Position, 0, oldBitmap);
RzPanel1.Canvas.Draw(pWidth + Position, 0, oldBitmap);
sleep(50);
Application.ProcessMessages;
if Position = -pWidth - TxtWidth then
Position := -TxtWidth;
Dec(Position);
end;
end;
相关文章推荐
- 一个文字淡入淡出的例子(Delphi7测试通过)
- android如何写一个循环文字滚动的TextView
- android怎样写一个循环文字滚动的TextView
- 黑马程序员之WinForm编程基础学习笔记:页面上有一个文本框,文本框左侧和右侧各有一个按钮,点击左测按钮文本框中的文字向左循环滚动一次,点击右侧按钮文本框中的文字向右循环滚动一次。
- 基于jquery可配置循环左右滚动例子
- 通过一个实际的例子学习Oracle存储过程
- html中表table行循环滚动例子
- 自己写了一个通过smarty与php相互结合的例子,动态生成静态程序,写的很烂
- Echarts循环显示的一个例子
- 解决曾经一个父布局循环添加子布局错误例子
- 通过一个实际的例子学习SQLServer存储过程
- 文字标签循环滚动
- 分享一个JQuery写的点击上下滚动的小例子
- 通过ArrayCollection对象的collectionChange事件,verticalScrollPosition以及maxVerticalScrollPosition属性创建一个自动滚动
- Flex中通过监听ObjectProxy的propertyChange事件检测一个Object是否变化的例子
- 通过官网的一个例子来看Activity的分组管理
- mybatis源码解析 - 通过一个简单查询例子分析流程
- 通过一个简单的例子学会vuex与模块化
- Flex中通过verticalScrollPosition和maxVerticalScrollPosition属性控制TextArea内文本滚动的例子
- 兼容各种浏览器的文字循环无缝滚动效果