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

📄 u_mian.pas

📁 中文字库文件应用
💻 PAS
字号:
unit U_mian;

interface

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

type
  TByteFile=File of byte;
  TByteArray=array[0..31] of byte;
  TForm1 = class(TForm)
    Shape1: TShape;
    Shape2: TShape;
    Shape3: TShape;
    Shape4: TShape;
    Shape5: TShape;
    Shape6: TShape;
    Shape7: TShape;
    Shape8: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Shape16: TShape;
    Shape17: TShape;
    Shape18: TShape;
    Shape19: TShape;
    Shape20: TShape;
    Shape21: TShape;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    Shape26: TShape;
    Shape27: TShape;
    Shape28: TShape;
    Shape29: TShape;
    Shape30: TShape;
    Shape31: TShape;
    Shape32: TShape;
    Shape33: TShape;
    Shape34: TShape;
    Shape35: TShape;
    Shape36: TShape;
    Shape37: TShape;
    Shape38: TShape;
    Shape39: TShape;
    Shape40: TShape;
    Shape41: TShape;
    Shape42: TShape;
    Shape43: TShape;
    Shape44: TShape;
    Shape45: TShape;
    Shape46: TShape;
    Shape47: TShape;
    Shape48: TShape;
    Shape49: TShape;
    Shape50: TShape;
    Shape51: TShape;
    Shape52: TShape;
    Shape53: TShape;
    Shape54: TShape;
    Shape55: TShape;
    Shape56: TShape;
    Shape57: TShape;
    Shape58: TShape;
    Shape59: TShape;
    Shape60: TShape;
    Shape61: TShape;
    Shape62: TShape;
    Shape63: TShape;
    Shape64: TShape;
    Shape65: TShape;
    Shape66: TShape;
    Shape67: TShape;
    Shape68: TShape;
    Shape69: TShape;
    Shape70: TShape;
    Shape71: TShape;
    Shape72: TShape;
    Shape73: TShape;
    Shape74: TShape;
    Shape75: TShape;
    Shape76: TShape;
    Shape77: TShape;
    Shape78: TShape;
    Shape79: TShape;
    Shape80: TShape;
    Shape81: TShape;
    Shape82: TShape;
    Shape83: TShape;
    Shape84: TShape;
    Shape85: TShape;
    Shape86: TShape;
    Shape87: TShape;
    Shape88: TShape;
    Shape89: TShape;
    Shape90: TShape;
    Shape91: TShape;
    Shape92: TShape;
    Shape93: TShape;
    Shape94: TShape;
    Shape95: TShape;
    Shape96: TShape;
    Shape97: TShape;
    Shape98: TShape;
    Shape99: TShape;
    Shape100: TShape;
    Shape101: TShape;
    Shape102: TShape;
    Shape103: TShape;
    Shape104: TShape;
    Shape105: TShape;
    Shape106: TShape;
    Shape107: TShape;
    Shape108: TShape;
    Shape109: TShape;
    Shape110: TShape;
    Shape111: TShape;
    Shape112: TShape;
    Shape113: TShape;
    Shape114: TShape;
    Shape115: TShape;
    Shape116: TShape;
    Shape117: TShape;
    Shape118: TShape;
    Shape119: TShape;
    Shape120: TShape;
    Shape121: TShape;
    Shape122: TShape;
    Shape123: TShape;
    Shape124: TShape;
    Shape125: TShape;
    Shape126: TShape;
    Shape127: TShape;
    Shape128: TShape;
    Shape129: TShape;
    Shape130: TShape;
    Shape131: TShape;
    Shape132: TShape;
    Shape133: TShape;
    Shape134: TShape;
    Shape135: TShape;
    Shape136: TShape;
    Shape137: TShape;
    Shape138: TShape;
    Shape139: TShape;
    Shape140: TShape;
    Shape141: TShape;
    Shape142: TShape;
    Shape143: TShape;
    Shape144: TShape;
    Shape145: TShape;
    Shape146: TShape;
    Shape147: TShape;
    Shape148: TShape;
    Shape149: TShape;
    Shape150: TShape;
    Shape151: TShape;
    Shape152: TShape;
    Shape153: TShape;
    Shape154: TShape;
    Shape155: TShape;
    Shape156: TShape;
    Shape157: TShape;
    Shape158: TShape;
    Shape159: TShape;
    Shape160: TShape;
    Shape161: TShape;
    Shape162: TShape;
    Shape163: TShape;
    Shape164: TShape;
    Shape165: TShape;
    Shape166: TShape;
    Shape167: TShape;
    Shape168: TShape;
    Shape169: TShape;
    Shape170: TShape;
    Shape171: TShape;
    Shape172: TShape;
    Shape173: TShape;
    Shape174: TShape;
    Shape175: TShape;
    Shape176: TShape;
    Shape177: TShape;
    Shape178: TShape;
    Shape179: TShape;
    Shape180: TShape;
    Shape181: TShape;
    Shape182: TShape;
    Shape183: TShape;
    Shape184: TShape;
    Shape185: TShape;
    Shape186: TShape;
    Shape187: TShape;
    Shape188: TShape;
    Shape189: TShape;
    Shape190: TShape;
    Shape191: TShape;
    Shape192: TShape;
    Shape193: TShape;
    Shape194: TShape;
    Shape195: TShape;
    Shape196: TShape;
    Shape197: TShape;
    Shape198: TShape;
    Shape199: TShape;
    Shape200: TShape;
    Shape201: TShape;
    Shape202: TShape;
    Shape203: TShape;
    Shape204: TShape;
    Shape205: TShape;
    Shape206: TShape;
    Shape207: TShape;
    Shape208: TShape;
    Shape209: TShape;
    Shape210: TShape;
    Shape211: TShape;
    Shape212: TShape;
    Shape213: TShape;
    Shape214: TShape;
    Shape215: TShape;
    Shape216: TShape;
    Shape217: TShape;
    Shape218: TShape;
    Shape219: TShape;
    Shape220: TShape;
    Shape221: TShape;
    Shape222: TShape;
    Shape223: TShape;
    Shape224: TShape;
    Shape225: TShape;
    Shape226: TShape;
    Shape227: TShape;
    Shape228: TShape;
    Shape229: TShape;
    Shape230: TShape;
    Shape231: TShape;
    Shape232: TShape;
    Shape233: TShape;
    Shape234: TShape;
    Shape235: TShape;
    Shape236: TShape;
    Shape237: TShape;
    Shape238: TShape;
    Shape239: TShape;
    Shape240: TShape;
    Shape241: TShape;
    Shape242: TShape;
    Shape243: TShape;
    Shape244: TShape;
    Shape245: TShape;
    Shape246: TShape;
    Shape247: TShape;
    Shape248: TShape;
    Shape249: TShape;
    Shape250: TShape;
    Shape251: TShape;
    Shape252: TShape;
    Shape253: TShape;
    Shape254: TShape;
    Shape255: TShape;
    Shape256: TShape;
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
   private
    { Private declarations }
    procedure hzconver(hz:TByteArray);
    procedure DrawMap();
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  dispboard:array[0..15,0..15] of integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  str2:string;
  int1,int2,int3:integer;

  bytefile:TByteFile;
  bytearray:TByteArray;
  tempint:Integer;
begin
  str2:=Edit1.Text;
  if str2='' then
  begin
    ShowMessage('不能为空');
    Exit;
  end;
  int1:=byte(str2[1]);
  int2:=byte(str2[2]);
  if ((int1< $a1) and (int2< $a1)) then
  begin
    ShowMessage('请输入汉字');
    Exit;
  end;
  int3:=((int1-$a1)*94+(int2-$a1))*32;

  AssignFile(bytefile,'hzk16.hzk');
  Reset(bytefile);
  Seek(bytefile,int3);

  for tempint:= 0 to 31 do
  begin
    read(bytefile,bytearray[tempint])
  end;
  CloseFile(bytefile);

  hzconver(bytearray);
  DrawMap();
end;

//将字库中的点阵数据转换成棋盘上点的点阵数据//
procedure TForm1.hzconver(hz:TByteArray);
var
  i,j,k:integer;
  ch,andflag:integer;
  hzz:array[0..15,0..1] of integer;
begin
  k:=0;
  for i:=0 to 15 do
  begin
    for j:=0 to 1 do
    begin
      hzz[i][j]:=hz[k];
      k:=k+1;
    end;
  end;

  for i:=0 to 15 do
  begin
    andflag:=$80;
    for j:=0 to 7 do
    begin
      ch:=hzz[i,0];
      ch:=ch and andflag;
      if(ch<>0) then
        dispboard[i][j]:=1
      else
        dispboard[i][j]:=0;
      andflag:=andflag shr 1;
    end;

    andflag:=$80;
    for j:=8 to 15 do
    begin
      ch:=hzz[i,1];
      ch:=ch and andflag;
      if(ch<>0) then
        dispboard[i][j]:=1
      else
        dispboard[i][j]:=0;
      andflag:=andflag shr 1;
    end;
  end;
end;

procedure TForm1.DrawMap();
var
  i,j:integer;
  str1:string;
begin
  for i:=0 to 15 do
    for j:=0 to 15 do
    begin
      if dispboard[i,j]=1 then
        begin
          str1:='shape' + IntToStr(i*16+j+1);
          TShape(FindComponent(str1)).brush.color:=clRed;
        end
      else
        begin
          str1:='shape' + IntToStr(i*16+j+1);
          TShape(FindComponent(str1)).brush.color:=clWhite;
        end;
    end;
end;

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key=13 then
  begin
    Button1.Click();
    Edit1.SelectAll;
    Edit1.Focused;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Edit1.SetFocus;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  Edit1.SetFocus;
end;

end.

⌨️ 快捷键说明

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