📄 testmain.pas
字号:
unit TestMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, XPMan, StdCtrls, ExtCtrls, SMGWSimThread;
type
TMainForm = class(TForm)
btnBatchSend: TButton;
XPMan: TXPManifest;
adoConn: TADOConnection;
edtSendCount: TEdit;
cmbSendType: TComboBox;
lblSendType: TLabel;
lblSendCount: TLabel;
btnSetConn: TButton;
btnSmgwSim: TButton;
bvlSend: TBevel;
lblLogin: TLabel;
edtLogin: TEdit;
lblSharedKey: TLabel;
edtSharedKey: TEdit;
bvlSimulation: TBevel;
lblMsgContent: TLabel;
edtMsgContent: TEdit;
btnDeliverMsg: TButton;
procedure btnBatchSendClick(Sender: TObject);
procedure btnSetConnClick(Sender: TObject);
procedure btnSmgwSimClick(Sender: TObject);
procedure btnDeliverMsgClick(Sender: TObject);
private
{ Private declarations }
FSmgwThrd: TSMGWSimThread;
procedure ThrdExecuteMsgHandler(var msg: TMessage); message UM_THRD_EXECUTE;
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
uses
General;
procedure TMainForm.btnBatchSendClick(Sender: TObject);
begin
ShowMessage(
Format('编写代码以通过数据库控制短信平台向网关发送%s信息。',
[cmbSendType.Text]));
end;
procedure TMainForm.btnSetConnClick(Sender: TObject);
begin
if adoConn.Connected then
adoConn.Close;
adoConn.ConnectionString := PromptDataSource(Self.Handle, adoConn.ConnectionString);
end;
procedure TMainForm.btnSmgwSimClick(Sender: TObject);
begin
// todo: start smgw simulation here
if not Assigned(FSmgwThrd) then begin
btnSmgwSim.Enabled := False;
FSmgwThrd := TSMGWSimThread.Create;
FSmgwThrd.Login := Trim(edtLogin.Text);
FSmgwThrd.SharedKey := Trim(edtSharedKey.Text);
FSmgwThrd.MainHandle := Application.MainForm.Handle;
FSmgwThrd.Resume;
btnSmgwSim.Caption := 'Stop SMGW simulation';
btnSmgwSim.Enabled := True;
end
else begin
btnSmgwSim.Enabled := False;
FSmgwThrd.Terminate;
FSmgwThrd.WaitFor;
FreeAndNil(FSmgwThrd);
btnSmgwSim.Caption := 'Start SMGW simulation';
btnSmgwSim.Enabled := True;
end;
end;
procedure TMainForm.btnDeliverMsgClick(Sender: TObject);
begin
if Assigned(FSmgwThrd) then
FSmgwThrd.DeliverMsg(Trim(edtMsgContent.Text));
end;
procedure TMainForm.ThrdExecuteMsgHandler(var msg: TMessage);
begin
btnSmgwSim.Click;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -