📄 unit8.pas
字号:
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, ExtCtrls, MyClass;
type
TfmDetect = class(TForm)
StringGrid1: TStringGrid;
GroupBox1: TGroupBox;
BitBtn1: TBitBtn;
GroupBox2: TGroupBox;
StringGrid2: TStringGrid;
BitBtn2: TBitBtn;
Timer1: TTimer;
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
GridIndex1,GridIndex2:integer;
//显示一个房间网格
procedure DisplayOneRoom(Good:Boolean;Line:word;GridIndex:word);
end;
var
fmDetect: TfmDetect;
implementation
{$R *.dfm}
Uses Unit1;
procedure TfmDetect.BitBtn1Click(Sender: TObject);
var i:integer;
begin
//开始检测
if(BitBtn1.Caption='开始检测') then begin
Timer1.Enabled:=true;
//清除原先的显示
for i:=0 to 255 do begin
StringGrid1.Cells[i mod 16,i div 16]:='';
StringGrid2.Cells[i mod 16,i div 16]:='';
end;
BitBtn1.Caption:='停止检测';
GridIndex1:=0; GridIndex2:=0;
Caller.RoomDetectStarted:=true;
end
else begin
Timer1.Enabled:=false;
BitBtn1.Caption:='开始检测';
Caller.RoomDetectStarted:=false;
//保存房间设置
//fmMain.LoadStoreRoomState(false);
end;
end;
procedure TfmDetect.FormShow(Sender: TObject);
var i:integer;
begin
//清除原先的显示
for i:=0 to 255 do begin
StringGrid1.Cells[i mod 16,i div 16]:='';
StringGrid2.Cells[i mod 16,i div 16]:='';
end;
//设置边界位置
fmDetect.Left:=(Screen.Width-fmDetect.Width)div 2;
if(fmDetect.Left<0) then fmDetect.Left:=0;
fmDetect.Top:=(Screen.Height-fmDetect.Height)div 2;
if(fmDetect.Top<0) then fmDetect.Top:=0;
end;
//显示一个房间网格
procedure TfmDetect.DisplayOneRoom(Good:Boolean;Line:word;GridIndex:word);
var str:string;
w,h:integer;
index:integer;
begin
if(fmMain.tbRoom.Locate('线路',Line,[]))then
str:=fmMain.tbRoom.FieldByName('房间号码').AsString
else
str:='无';
if(Good) then begin
StringGrid1.Cells[GridIndex mod 16,GridIndex div 16]:=str;
end
else begin
StringGrid2.Cells[GridIndex mod 16,GridIndex div 16]:=str;
end;
end;
procedure TfmDetect.Timer1Timer(Sender: TObject);
var str:string;
Good:Boolean;
RoomNumber:word;
GridIndex:integer;
begin
Timer1.Enabled:=false;
Timer1.Enabled:=true;
if(Caller.RoomDetectStarted) then begin
RoomNumber:=(Caller.LineIndex shr 4+1)*100+(Caller.LineIndex and $0f+1);
Good:=Caller.RoomExist(RoomNumber);
if(Good) then begin
GridIndex:=GridIndex1;
GridIndex1:=GridIndex1+1;
end
else begin
GridIndex:=GridIndex2;
GridIndex2:=GridIndex2+1;
end;
DisplayOneRoom(Good,RoomNumber,GridIndex);
//准备下一个检测
Caller.LineIndex:=Caller.LineIndex+1;
if(Caller.LineIndex>=255) then begin
Timer1.Enabled:=false;
BitBtn1.Caption:='开始检测';
//SendMessage(BitBtn1.Handle,BM_CLICK,0,0);
//保存房间设置
fmMain.LoadStoreRoomState(false);
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -