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

📄 setcomm.pas

📁 delphi6.0电子寻更源程序,用来计算保安有无查抄
💻 PAS
字号:
unit setcomm;

interface

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

type
  TsetcommForm = class(TForm)
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    Panel2: TPanel;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormActivate(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure FormPaint(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  setcommForm: TsetcommForm;

implementation
   uses menu;
{$R *.DFM}

procedure TsetcommForm.FormCreate(Sender: TObject);
var
  s2:pchar;
  INIFile:string;
begin

  getmem(s2,10);
  combobox2.text:=combobox2.items[1];
  //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';
  GetPrivateProfileString('comports','comportsnumber','0',s2,5, pchar(INIFile));
  IF	s2='0' THEN combobox1.ItemIndex:=0
  ELSE
    IF	s2='1' THEN combobox1.ItemIndex:=1
    ELSE
      IF	s2='2' THEN combobox1.ItemIndex:=2
    	ELSE
        IF	s2='3' THEN combobox1.ItemIndex:=3
       	ELSE	combobox1.ItemIndex:=0;
{       DWORD GetPrivateProfileString(

    LPCTSTR  lpAppName,	// points to section name
    LPCTSTR  lpKeyName,	// points to key name
    LPCTSTR  lpDefault,	// points to default string
    LPTSTR  lpReturnedString,	// points to destination buffer
    DWORD  nSize,	// size of destination buffer
    LPCTSTR  lpFileName 	// points to initialization filename
   );}
  freemem(s2);
end;

procedure TsetcommForm.Button1Click(Sender: TObject);
var
  p:pchar;
  INIFile:string;
  number1:longbool;
begin
  try
    if  combobox1.itemindex <0 then
    begin
      Application.MessageBox('串行口设置不正确','消息',MB_ICONINFORMATION);
      exit;
    end;
    //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';
    number1:=writeprivateprofilestring('comports','comportsnumber',
             pchar(inttostr(combobox1.itemindex)),
             pchar(INIFile));
    if number1=false then
         Application.MessageBox('串口设置失败','消息',MB_ICONINFORMATION)
    else
    begin
    Application.MessageBox('串口设置成功!','消息',MB_ICONINFORMATION);
    self.Close;
    end;
  finally
    freemem(p);
  end;
end;

procedure TsetcommForm.FormShow(Sender: TObject);
begin
 { scaled:=true;
  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 TsetcommForm.BitBtn3Click(Sender: TObject);
begin
close;
end;

procedure TsetcommForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  action:=cafree;
  setcommForm :=nil ;
end;

procedure TsetcommForm.FormActivate(Sender: TObject);
begin
self.Height:=172;
self.Width:=269;
self.Top:=100;
self.Left:=round((mainform.Width-self.Width)/2);
end;

procedure TsetcommForm.FormResize(Sender: TObject);
begin
self.Height:=172;
self.Width:=269;
self.Top:=100;
self.Left:=round((mainform.Width-self.Width)/2);

end;

procedure TsetcommForm.FormPaint(Sender: TObject);
begin
self.Height:=172;
self.Width:=269;
self.Top:=100;
self.Left:=round((mainform.Width-self.Width)/2);

end;

end.

⌨️ 快捷键说明

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