热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

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

程序把一个文本文件在屏幕上缓慢输出,完全输出后再从头循环输出修改后可以使用的程序源代码(还是不完善:还不能实现从一侧飞入的效果,容易出错):unitUnit1;interfaceus

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

修改后可以使用的程序源代码(还是不完善:还不能实现从一侧飞入的效果,容易出错):
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
  b100';
  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


推荐阅读
  • YOLOv7基于自己的数据集从零构建模型完整训练、推理计算超详细教程
    本文介绍了关于人工智能、神经网络和深度学习的知识点,并提供了YOLOv7基于自己的数据集从零构建模型完整训练、推理计算的详细教程。文章还提到了郑州最低生活保障的话题。对于从事目标检测任务的人来说,YOLO是一个熟悉的模型。文章还提到了yolov4和yolov6的相关内容,以及选择模型的优化思路。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 不同优化算法的比较分析及实验验证
    本文介绍了神经网络优化中常用的优化方法,包括学习率调整和梯度估计修正,并通过实验验证了不同优化算法的效果。实验结果表明,Adam算法在综合考虑学习率调整和梯度估计修正方面表现较好。该研究对于优化神经网络的训练过程具有指导意义。 ... [详细]
  • 本文讨论了在手机移动端如何使用HTML5和JavaScript实现视频上传并压缩视频质量,或者降低手机摄像头拍摄质量的问题。作者指出HTML5和JavaScript无法直接压缩视频,只能通过将视频传送到服务器端由后端进行压缩。对于控制相机拍摄质量,只有使用JAVA编写Android客户端才能实现压缩。此外,作者还解释了在交作业时使用zip格式压缩包导致CSS文件和图片音乐丢失的原因,并提供了解决方法。最后,作者还介绍了一个用于处理图片的类,可以实现图片剪裁处理和生成缩略图的功能。 ... [详细]
  • 本文介绍了深入浅出Linux设备驱动编程的重要性,以及两种加载和删除Linux内核模块的方法。通过一个内核模块的例子,展示了模块的编译和加载过程,并讨论了模块对内核大小的控制。深入理解Linux设备驱动编程对于开发者来说非常重要。 ... [详细]
  • 预备知识可参考我整理的博客Windows编程之线程:https:www.cnblogs.comZhuSenlinp16662075.htmlWindows编程之线程同步:https ... [详细]
  • 海马s5近光灯能否直接更换为H7?
    本文主要介绍了海马s5车型的近光灯是否可以直接更换为H7灯泡,并提供了完整的教程下载地址。此外,还详细讲解了DSP功能函数中的数据拷贝、数据填充和浮点数转换为定点数的相关内容。 ... [详细]
  • IOS开发之短信发送与拨打电话的方法详解
    本文详细介绍了在IOS开发中实现短信发送和拨打电话的两种方式,一种是使用系统底层发送,虽然无法自定义短信内容和返回原应用,但是简单方便;另一种是使用第三方框架发送,需要导入MessageUI头文件,并遵守MFMessageComposeViewControllerDelegate协议,可以实现自定义短信内容和返回原应用的功能。 ... [详细]
  • 手把手教你使用GraphPad Prism和Excel绘制回归分析结果的森林图
    本文介绍了使用GraphPad Prism和Excel绘制回归分析结果的森林图的方法。通过展示森林图,可以更加直观地将回归分析结果可视化。GraphPad Prism是一款专门为医学专业人士设计的绘图软件,同时也兼顾统计分析的功能,操作便捷,可以帮助科研人员轻松绘制出高质量的专业图形。文章以一篇发表在JACC杂志上的研究为例,利用其中的多因素回归分析结果来绘制森林图。通过本文的指导,读者可以学会如何使用GraphPad Prism和Excel绘制回归分析结果的森林图。 ... [详细]
  • 全面介绍Windows内存管理机制及C++内存分配实例(四):内存映射文件
    本文旨在全面介绍Windows内存管理机制及C++内存分配实例中的内存映射文件。通过对内存映射文件的使用场合和与虚拟内存的区别进行解析,帮助读者更好地理解操作系统的内存管理机制。同时,本文还提供了相关章节的链接,方便读者深入学习Windows内存管理及C++内存分配实例的其他内容。 ... [详细]
  • Gitlab接入公司内部单点登录的安装和配置教程
    本文介绍了如何将公司内部的Gitlab系统接入单点登录服务,并提供了安装和配置的详细教程。通过使用oauth2协议,将原有的各子系统的独立登录统一迁移至单点登录。文章包括Gitlab的安装环境、版本号、编辑配置文件的步骤,并解决了在迁移过程中可能遇到的问题。 ... [详细]
author-avatar
toelleconneely_348
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有