📄 mainunt.pas
字号:
unit MainUnt;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons;
type
TMainFrm = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
GroupBox2: TGroupBox;
Label1: TLabel;
edt1: TEdit;
Button2: TButton;
GroupBox1: TGroupBox;
edt2: TEdit;
edt3: TEdit;
edtFile: TEdit;
Label2: TLabel;
Label3: TLabel;
OpenDialog1: TOpenDialog;
SpeedButton1: TSpeedButton;
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
gFileName:string;
function GetShape(aName: string): TShape;
public
{ Public declarations }
end;
var
MainFrm: TMainFrm;
implementation
{$R *.dfm}
procedure TMainFrm.Button2Click(Sender: TObject);
var
offVar: integer;
hz1, hz2: byte;
TmpStr: string;
TmpFile: file of byte;
Tmpbyte1, TmpByte2: byte;
i, j, k: integer;
Tmpsp: TShape;
begin
tmpStr := edt1.Text;
hz1 := ord(TmpStr[1]);
hz2 := ord(TmpStr[2]);
edt2.Text := IntToHex(hz1,2);
edt3.Text := IntToHex(hz2,2);
offVar := ((hz1 - $A1) * 94 + (hz2 - $A1)) * 32;
assignFile(TmpFile, gFileName);
reset(TmpFile);
seek(TmpFile, offVar);
for k := 1 to 2 do
begin
for i := 1 to 16 do
begin
read(TmpFile, tmpByte1);
for j := 1 to 8 do
begin
TmpStr := 'sp_' + IntToStr((k-1)*8+j) + '_' + IntToStr(i);
Tmpsp := GetShape(TmpStr);
if tmpSp <> nil then
begin
if (tmpByte1 and $1) = 1 then //黑色
Tmpsp.Pen.Mode := pmBlack
else //白色
Tmpsp.Pen.Mode := pmWhite;
end;
tmpByte1 := tmpByte1 shr 1;
end;
end;
end;
closeFile(TmpFile);
end;
function TMainFrm.GetShape(aName: string): TShape;
var
i: integer;
begin
result := nil;
for i := 0 to panel1.ComponentCount - 1 do
begin
if (uppercase(panel1.Components[i].Name) = UpperCase(aName)) and
(panel1.Components[i] is TShape) then
begin
result := panel1.Components[i] as TShape;
exit;
end;
end;
end;
procedure TMainFrm.FormShow(Sender: TObject);
var
i, j: integer;
Tmpsp: TShape;
begin
if panel1.ComponentCount>0 then exit;
for i := 1 to 16 do
for j := 1 to 16 do
begin
Tmpsp := TShape.Create(Panel1);
Tmpsp.Visible := True;
TmpSp.Parent := Panel1;
TmpSp.Top := 100 + (i - 1) * 11;
TmpSp.Left := 20 + (j - 1) * 11;
Tmpsp.Width := 10;
TmpSp.Height := 10;
tmpsp.Name := 'sp_' + IntToStr(i) + '_' + IntToStr(j);
end;
gFileName := extractFilePath(paramstr(0))+'\hzk16.bin';
end;
procedure TMainFrm.SpeedButton1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
edtfile.Text := OpenDialog1.FileName;
gFileName :=edtfile.Text;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -