📄 initframe.~pas
字号:
unit initframe;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls,recethr,gvas, RXCtrls, Buttons;
type
TinitframeForm = class(TForm)
COMMSB: TStatusBar;
Panel1: TPanel;
EXITBTN: TBitBtn;
COMMBTN: TBitBtn;
Panel2: TPanel;
Bevel1: TBevel;
RxLabel1: TRxLabel;
Edit_count: TEdit;
procedure FormShow(Sender: TObject);
procedure COMMBTNClick(Sender: TObject);
procedure EXITBTNClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormPaint(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
procedure threaddone(SENDER:TOBJECT);
procedure echomess(var x1:tmessage); message wm_Message1;
public
{ Public declarations }
end;
var
initframeForm: TinitframeForm;
implementation
uses menu;
{$R *.DFM}
procedure TInitFrameForm.commbtnClick(Sender: TObject);
var
p1:pchar;
comname,INIFile:string;
wasconnect:boolean;
wcou:word;
begin
CommSB.panels[0].text:='';
CommSB.panels[1].text:='';
CommSB.panels[2].text:='';
try
getmem(p1,16);
comname:='';
//INIFile:=ExtractFileDir(APPLICATION.EXENAME)+'\HdXGXT.INI';
inifile:=ExtractFiledir(APPLICATION.EXENAME)+'\'+ExtractFilename(APPLICATION.EXENAME);//+'\hdxgxt.ini';
if not fileexists(inifile) then
inifile:=ExtractFileDir(APPLICATION.EXENAME)+'hdxgxt.ini'
else inifile:=extractfiledir(application.exename)+'\hdxgxt.ini';
if not fileexists(INIFile) then
begin
Application.MessageBox('需要设定串行通讯口','消息',MB_ICONINFORMATION);
exit;
end else
begin
getprivateprofilestring('comports','comportsnumber','01',p1,16,pchar(INIFile));
comname:=p1;
if strtoint(comname)<0 then
begin
Application.MessageBox('串口设置信息丢失,请重新设置串行口','消息',MB_ICONINFORMATION);
exit;
end;
wcou:=strtointdef(edit_count.text,0);
with TInitPen.Create(self.handle,strtoint(comname)+1,commsb,wcou) do
BEGIN
OnTerminate := ThreadDone;
END;
CommBtn.enabled:=FALSE;
EXITBtn.Enabled:=FALSE;
end;
finally
freemem(p1,16);
end;
end;
procedure TInitFrameForm.echomess(var x1:tmessage);
BEGIN
case ord(x1.WParam) of
Msg_Comm:
begin
case ord(x1.lparam) of
Msg_Comm_InitSuccess:CommSB.Panels[0].TEXT:='串口初始化成功';
Msg_Comm_InitFale:Application.MessageBox('串口初始化出错','消息',MB_ICONINFORMATION);
Msg_Comm_DeviceErr:Application.MessageBox('通讯设备不正常,请检查通讯器、连接线和电源','消息',MB_ICONINFORMATION);
end;
end;
Msg_Pen:
begin
case ord(x1.lparam) of
Msg_Pen_detecting:CommSB.Panels[1].text:='正在联接巡检笔..';
Msg_Pen_present:CommSB.Panels[1].text:='联接到巡检笔';
Msg_Pen_absent:CommSB.Panels[1].text:='联接巡检笔失败!';
Msg_Pen_InitPen:CommSB.Panels[2].text:='正在初始化笔...';
Msg_Pen_InitPensucc:CommSB.Panels[2].text:='初始化笔正确';
Msg_Pen_InitPenfale:CommSB.Panels[2].text:='初始化笔错误';
end;
end;
Msg_PCode:
begin
CommSB.Panels[1].Text:='笔号:'+IntTohex(x1.lparam,2);
end;
else ;
end;
END;
procedure TInitFrameForm.threaddone(SENDER:TOBJECT);
BEGIN
CommBtn.enabled:=true;
EXITBtn.Enabled:=true;
END;
procedure TinitframeForm.FormShow(Sender: TObject);
begin
{ height:=round(height*longint(screen.height)*96 / 600/screen.pixelsperinch);
width :=round( width *longint(screen.width)*96 / 800/screen.pixelsperinch);
ScaleControls(screen.width, 800);
ScaleControls(96,screen.pixelsperinch);
}end;
procedure TinitframeForm.EXITBTNClick(Sender: TObject);
begin
close;
end;
procedure TinitframeForm.FormActivate(Sender: TObject);
begin
self.Height:=196;
self.Width:=350;
self.Top:=100;
self.Left:=round((mainform.Width-self.Width)/2);
end;
procedure TinitframeForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
action:=cafree;
initframeForm :=nil ;
end;
procedure TinitframeForm.FormPaint(Sender: TObject);
begin
self.Height:=196;
self.Width:=350;
self.Top:=100;
self.Left:=round((mainform.Width-self.Width)/2);
end;
procedure TinitframeForm.FormResize(Sender: TObject);
begin
self.Height:=196;
self.Width:=350;
self.Top:=100;
self.Left:=round((mainform.Width-self.Width)/2);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -