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

📄 sendcountfrm.pas

📁 一个delphi编写的收发短信源码, 使用了Cport控件,很实用
💻 PAS
字号:
unit SendCountFrm;

interface

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

type
  TfrmSendCount = class(TForm)
    GroupBox1: TGroupBox;
    Label2: TLabel;
    Label1: TLabel;
    MCount: TMemo;
    L1: TLabel;
    SBOK: TSpeedButton;
    SBExit: TSpeedButton;
    Timer1: TTimer;
    SpeedButton1: TSpeedButton;
    edPhone: TIdComboBox;
    procedure SBOKClick(Sender: TObject);
    procedure SBExitClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure MCountKeyPress(Sender: TObject; var Key: Char);
    procedure Timer1Timer(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
    ClickOK: Boolean;
    mPhone, sCount: string;
    procedure LoadKeyNoList;
  public
    { Public declarations }
  end;

function Show_SendCount(var fPhone, fCount: string): Boolean;

var
  frmSendCount: TfrmSendCount;

implementation

uses SendMan;

function Show_SendCount(var fPhone, fCount: string): Boolean;
begin
  with TfrmSendCount.Create(nil) do
  begin
    ClickOK := False;
    LoadKeyNoList;
    try
      ShowModal;
    finally
      fPhone := mPhone;
      fCount := sCount;
      Result := ClickOK;
      Free;
    end;
  end;
end;

{$R *.DFM}

procedure TfrmSendCount.SBOKClick(Sender: TObject);
begin
//  edPhone.Text := Trim(edPhone.Text);
  MCount.Text := Trim(MCount.Text);
  if (edPhone.ItemIndex = -1) or (MCount.Text = '') then
  begin
    Application.MessageBox('资料输入不完整!', '系统提示', MB_OK + MB_ICONWARNING);
    Exit;
  end;
  mPhone := edPhone.Ids.Strings[edPhone.ItemIndex];
  sCount := MCount.Text;
  frmSMS.SendGSMMsg(mPhone, CommPort.Phone, sCount);
  ClickOK := True;
  //  Self.Close;
end;

procedure TfrmSendCount.SBExitClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmSendCount.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TfrmSendCount.MCountKeyPress(Sender: TObject; var Key: Char);
var
  Leg: integer;
begin
  Leg := Length(MCount.Text);
  {  L1.Caption := '(' + IntToStr(Leg) + '/140)';}
  if (Leg = 140) and (Key in ['0'..'9', 'A'..'F', 'a'..'f']) then
    Key := #0;
end;

procedure TfrmSendCount.Timer1Timer(Sender: TObject);
var
  Leg: integer;
begin
  try
    Timer1.Enabled := False;
    Leg := Length(MCount.Text);
    L1.Caption := '(' + IntToStr(Leg) + '/140)';
  finally
    Timer1.Enabled := True;
  end;
end;

procedure TfrmSendCount.SpeedButton1Click(Sender: TObject);
var
  TempList: TStrings;
  i: Integer;
  TempStr, Str1: string;
begin
  TempList := TStringList.Create;
  try
    if Show_SendMan(TempList) then
    begin
      edPhone.Items.Clear;
      edPhone.Ids.Clear;
      for i := 0 to TempList.Count - 1 do
      begin
        TempStr := GetsubStr(TempList.Strings[i], 1, '-');
        Str1 := Str1 + TempList.Strings[i] + ',';
        edPhone.Items.Add(TempList.Strings[i]);
        edPhone.Ids.Add(GetsubStr(TempList.Strings[i], 2, '-'));
      end;
      SetLength(Str1, Length(Str1) - 1);
      iniF.WriteString(KeyNoList, 'KeyNoList', Str1);
      edPhone.ItemIndex := 0;
    end;
  finally
    TempList.Free;
  end;
end;

procedure TfrmSendCount.LoadKeyNoList;
var
  i: integer;
  TempStr: string;
begin
  TempStr := iniF.ReadString(KeyNoList, 'KeyNoList', '');
  if TempStr <> '' then
  begin
    edPhone.Items.Clear;
    edPhone.Ids.Clear;
    for i := 1 to StrSubCount(TempStr, ',') + 1 do
    begin
      //edPhone.Items.Add(GetsubStr(GetsubStr(TempStr, i), 1, '-'));
      edPhone.Items.Add(GetsubStr(TempStr, i));
      edPhone.Ids.Add(GetsubStr(GetsubStr(TempStr, i), 2, '-'));
    end;
    edPhone.ItemIndex := 0;
  end;
end;

end.

⌨️ 快捷键说明

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