⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 Delphi高级界面特效制作百例源代码,这是随书源代码部分,不知可否
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    Timer1: TTimer;
    procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
      Panel: TStatusPanel; const Rect: TRect);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    //记录文字加入的起始点和文字的宽度
    f,w : Integer;

    //记录文字显示区域
    tmp_rect : TRect;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

//重画状态条
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
begin
     //记录要显示文字的区域值
     tmp_rect.Left := Rect.Left;
     tmp_rect.Top := Rect.Top;
     tmp_rect.Right := Rect.Right;
     tmp_rect.Bottom := Rect.Bottom;

     //得到文字显示起始点
     f := tmp_rect.Right;
end;

//定时器触发事件
procedure TForm1.Timer1Timer(Sender: TObject);
begin
     //显示文字
     with StatusBar1.Canvas do
     begin
          FillRect(tmp_rect);
          Font.Color := clBlack;
          w := TextWidth('欢 迎 进 入 Delphi 界 面 设 计 指 南 !');
          Pen.Style := psClear	;
          Rectangle(tmp_rect.Left,tmp_rect.Top,tmp_rect.Right,tmp_rect.Bottom);
          TextOut(f,tmp_rect.Top,'欢 迎 进 入 Delphi 界 面 设 计 指 南 !');
     end;

     //计算文字显示起始点
     if f > -w then
        f := f - 30
     else
         f := tmp_rect.Right;;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -