📄 rei_25.pas
字号:
unit Rei_25;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus, ExtCtrls;
type
TRei40_25 = class(TForm)
MainMenu1: TMainMenu;
Timer1: TTimer;
Bevel1: TBevel;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Timer1Timer(Sender: TObject);
private
{ Private 定义 }
procedure DpDgt(Dt: Byte; X, Y: Word);
public
{ Public 定义 }
end;
var
Rei40_25: TRei40_25;
// 定义数字图案用与绘制用的点阵图
Digit_Bmap: TBitmap;
Make_Bmap: TBitmap;
// 定义各种变量(TRect类型、数组类型)
Rect_S, Rect_D: TRect;
Duse: array[0..9] of Byte = (
$77, $60, $3E, $7C, $69, $5D, $5F, $64, $7F, $7D
);
implementation
{$R *.DFM}
procedure TRei40_25.FormCreate(Sender: TObject);
begin
// 设定Form属性
Rei40_25.Height := 480;
Rei40_25.Width := 640;
Rei40_25.Canvas.CopyMode := cmSrcCopy;
Bevel1.Height := 74;
Bevel1.Left := 90;
Bevel1.Top := 136;
Bevel1.Width := 444;
// 载入数字图案
Digit_Bmap := TBitmap.Create;
Digit_Bmap.LoadFromFile(GetCurrentDir + '\ExData\Digit.bmp');
// 储存绘制用点阵图
Make_Bmap := TBitmap.Create;
Make_Bmap.Height := 70;
Make_Bmap.Width := 440;
// 绘制时钟用的冒号
Make_Bmap.Canvas.Brush.Color := clWhite;
Rect_D := Rect(0, 0, Make_Bmap.Width, Make_Bmap.Height);
Make_Bmap.Canvas.FillRect(Rect_D);
Make_Bmap.Canvas.CopyMode := cmSrcCopy;
Rect_S := Rect(56, 8, 72, 40);
Rect_D := Rect(106, 18, 122, 50);
Make_Bmap.Canvas.CopyRect(Rect_D, Digit_Bmap.Canvas, Rect_S);
Rect_S := Rect(56, 24, 72, 40);
Rect_D := Rect(294, 42, 310, 58);
Make_Bmap.Canvas.CopyRect(Rect_D, Digit_Bmap.Canvas, Rect_S);
end;
procedure TRei40_25.Timer1Timer(Sender: TObject);
var
// 定义局部变量
H, M, S, MS: Word;
begin
// 绘制数字钟
Make_Bmap.Canvas.Brush.Color := clWhite;
Make_Bmap.Canvas.CopyMode := cmSrcCopy;
Rect_D := Rect(10, 18, 34, 50);
Make_Bmap.Canvas.FillRect(Rect_D);
DecodeTime(Time, H, M, S, MS);
if H >= 12 then
begin
H := H - 12;
Rect_S := Rect(0, 24, 24, 40);
Rect_D := Rect(10, 34, 34, 50);
end
else begin
Rect_S := Rect(0, 8, 24, 24);
Rect_D := Rect(10, 18, 34, 34);
end;
Make_Bmap.Canvas.CopyRect(Rect_D, Digit_Bmap.Canvas, Rect_S);
if H >= 10 then
begin
H := H - 10;
DpDgt(1, 34, 10);
end
else begin
Rect_D := Rect(50, 10, 66, 58);
Make_Bmap.Canvas.FillRect(Rect_D);
end;
DpDgt(H, 74, 10);
DpDgt(M div 10, 122, 10);
DpDgt(M mod 10, 162, 10);
DpDgt(S div 10, 218, 10);
DpDgt(S mod 10, 258, 10);
DpDgt(MS div 100, 314, 10);
MS := MS mod 100;
DpDgt(MS div 10, 354, 10);
DpDgt(MS mod 10, 394, 10);
// 显示数字钟
Rect_S := Rect(0, 0, 440, 70);
Rect_D := Rect(Bevel1.Left + 3, Bevel1.Top + 3,
Bevel1.Left + 440, Bevel1.Top + 70);
Rei40_25.Canvas.CopyRect(Rect_D, Make_Bmap.Canvas, Rect_S);
end;
procedure TRei40_25.DpDgt(Dt: Byte; X, Y: Word);
begin
// 绘制指定的液晶数字
Rect_S := Rect(24, 0, 56, 48);
Rect_D := Rect(X, Y, X + 32, Y + 48);
Make_Bmap.Canvas.CopyRect(Rect_D, Digit_Bmap.Canvas, Rect_S);
if (Duse[Dt] and 1) = 0 then
Make_Bmap.Canvas.FloodFill(X + 4, Y + 12, clWhite, fsBorder);
if (Duse[Dt] and 2) = 0 then
Make_Bmap.Canvas.FloodFill(X + 4, Y + 36, clWhite, fsBorder);
if (Duse[Dt] and 4) = 0 then
Make_Bmap.Canvas.FloodFill(X + 16, Y + 4, clWhite, fsBorder);
if (Duse[Dt] and 8) = 0 then
Make_Bmap.Canvas.FloodFill(X + 16, Y + 24, clWhite, fsBorder);
if (Duse[Dt] and 16) = 0 then
Make_Bmap.Canvas.FloodFill(X + 16, Y + 44, clWhite, fsBorder);
if (Duse[Dt] and 32) = 0 then
Make_Bmap.Canvas.FloodFill(X + 28, Y + 12, clWhite, fsBorder);
if (Duse[Dt] and 64) = 0 then
Make_Bmap.Canvas.FloodFill(X + 28, Y + 36, clWhite, fsBorder);
end;
procedure TRei40_25.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// 将数字图案用与绘制用的点阵图释放掉
Digit_Bmap.Free;
Make_Bmap.Free;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -