分享
 
 
 

关于拉幕程序的讨论和源码

王朝delphi·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

程序把一个文本文件在屏幕上缓慢输出,完全输出后再从头循环输出

修改后可以使用的程序源代码(还是不完善:还不能实现从一侧飞入的效果,容易出错):

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, ExtCtrls, ComCtrls, ColorGrd, RxCombos;

type

TForm1 = class(TForm)

Button1: TButton;

Edit1: TEdit;

OpenDialog1: TOpenDialog;

Button2: TButton;

Button3: TButton;

TrackBar1: TTrackBar;

Panel1: TPanel;

Panel2: TPanel;

Panel3: TPanel;

Label1: TLabel;

Label2: TLabel;

Timer1: TTimer;

Button4: TButton;

ColorDialog1: TColorDialog;

FontDialog1: TFontDialog;

Button6: TButton;

Button7: TButton;

ComboBox1: TComboBox;

Panel4: TPanel;

Edit2: TEdit;

Edit3: TEdit;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Edit4: TEdit;

Edit5: TEdit;

Button8: TButton;

Button5: TButton;

procedure Button1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure TrackBar1Change(Sender: TObject);

procedure FormDestroy(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure Button7Click(Sender: TObject);

procedure Button6Click(Sender: TObject);

procedure Button8Click(Sender: TObject);

procedure Button5Click(Sender: TObject);

private

procedure zShowText;

Procedure zBmpCreate;

procedure zSetBmp;

procedure zSetLineHeight;

procedure zShowLine(sender :TObject);

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.DFM}

const

bWidth=200;

var

currline, LineHeight:integer;

sItem:TStringList;

bmp:TBitMap;

bRect,R1:TRect;

iDc:HDC;

procedure TForm1.Button1Click(Sender: TObject);

begin

OpenDialog1.Execute;

Edit1.Text:=OpenDialog1.FileName;

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

Form1.WindowState:=wsMaximized;

Panel1.Top:=80;

Panel1.Left:=96;

Panel1.Height:=385;

Panel1.Width:=433;

Timer1.Enabled:=False;

Label2.Caption:='100';

iDC:=GetDc(Panel1.handle);

Currline:=0;

end;

procedure TForm1.zShowLine(sender :TObject);

begin

zShowText;

end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin

zShowLine(self);//显示字符串

//bitblt 转移矩形图 (目标句柄,LS x,y,宽,高,源句柄,LS x,y,光栅运算符)

BitBlt(iDc,0,0,Panel1.Width,Panel1.Height,

Bmp.Canvas.Handle,0,Currline,srcCopy);

Inc(Currline,1);

if Currline>=bRect.Bottom-panel1.Height+100 then//循环条件?

begin

Timer1.Enabled:=False;

Currline:=0;

end;

end;

procedure TForm1.zShowText;

var

i:integer;

ss:string;

ReadFile:TextFile;

begin

AssignFile(ReadFile,Edit1.Text);

Reset(ReadFile);

i:=1;

sItem:=TStringList.Create;

with sItem do

while not eof(ReadFile) do

begin

Readln(ReadFile,ss);

add(ss);

i:=i+1;

end;

CloseFile(ReadFile);

zBmpCreate;

sItem.Free;//释放串

end;

procedure TForm1.zBmpCreate; //创建图片

var

i,y:integer; //y

begin

if bmp<>nil then bmp.free;

bmp:=TBitMap.Create;

zSetBmp;

R1.Right:=bRect.Right;

R1.Bottom:=bRect.Bottom;

y:=Panel1.Height-100;

for i:=0 to sItem.Count-1 do // 从0到行数 循环显示图片

begin

R1.Top:=y;

R1.Bottom:=R1.Top+LineHeight;

if Combobox1.Text='中间对齐' then //显示图片

DrawText(Bmp.Canvas.Handle,pChar(sItem[i]),-1,R1,Dt_Center or Dt_Top)

else

if Combobox1.Text='左对齐' then

DrawText(Bmp.Canvas.Handle,pChar(sItem[i]),-1,R1,Dt_Left or Dt_Top)

else

if Combobox1.Text='右对齐'then

DrawText(Bmp.Canvas.Handle,pChar(sItem[i]),-1,R1,Dt_Right or Dt_Top)

else

DrawText(Bmp.Canvas.Handle,pChar(sItem[i]),-1,R1,Dt_Center or Dt_Top);

Inc(y,LineHeight);

end;

end;

procedure TForm1.zSetBmp;

begin

zSetLineHeight;

with bRect do //Rect 矩形坐标(左上x,左下y,右上x,右下y)

begin

Top:=0;

Left:=0;

Right:=Panel1.Width;

Bottom:=LineHeight*sItem.Count+Height;//行高*行数+form高度

end;

with Bmp do

begin

Height:=bRect.Bottom+100;//图片高度

Width:=bRect.Right;

with Canvas do //canvas 画布

begin

Font:=FontDialog1.Font;

//Font:=self.Font;//form所设置的字体

Brush.Color:=ColorDialog1.Color;

FillRect(bRect);

Brush.Style:=bsClear;

end;

end;

end;

procedure TForm1.zSetLineHeight;

{设置行间隔}

var

Metrics:TTextMetric; //设置字体 API

begin

GetTextMetrics(iDc,Metrics);

LineHeight:=Metrics.tmHeight+Metrics.tmInternalLeading-Bmp.Canvas.Font.Height;

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

if Edit1.Text='' then ShowMessage('请输入文件地址')

else

begin

if Button2.Caption='开始' then Button2.Caption:='暂停'

else Button2.Caption:='开始';

Timer1.Enabled:=not Timer1.Enabled;

end;

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

timer1.Enabled :=false;

Currline:=0;

Button2.Click;

Button2.Caption:='暂停';

end;

procedure TForm1.TrackBar1Change(Sender: TObject);

begin

Timer1.Interval:=TrackBar1.Position*5;

Label2.Caption:=inttostr(Timer1.Interval);

end;

procedure TForm1.FormDestroy(Sender: TObject);

begin

if Bmp<>nil then Bmp.Free;

end;

procedure TForm1.Button4Click(Sender: TObject);

begin

close;

end;

procedure TForm1.Button7Click(Sender: TObject);

begin

FontDialog1.Execute;

end;

procedure TForm1.Button6Click(Sender: TObject);

begin

ColorDialog1.Execute;

end;

procedure TForm1.Button8Click(Sender: TObject);

begin

if ((strtoint(Edit2.Text)>=600) or (strtoint(Edit3.text)>=500) or ((strtoint(Edit5.Text)>=553) or (strtoint(Edit4.Text)>=630)))

then showmessage('范围超界')

else

begin

Panel1.Top:=strtoint(Edit2.text);

Panel1.Left:=strtoint(Edit3.text);

Panel1.Width:=strtoint(Edit4.text);

Panel1.Height:=strtoint(Edit5.text);

end;

end;

procedure TForm1.Button5Click(Sender: TObject);

begin

Panel1.Top:=0;

Panel1.Left:=0;

Panel1.Width:=Panel3.Width;

Panel1.Height:=Panel3.Height;

end;

end.

详细讨论在:http://www.csdn.net/expert/topic/97/97371.shtm

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有