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

📄 testmsgvoc.pas

📁 Voice Modem 使用源码
💻 PAS
字号:
unit TestMsgVoc;

interface

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

type
  TForm1 = class(TForm)
    BtnGoInit: TButton;
    Label1: TLabel;
    LblCounter: TLabel;
    Timer1: TTimer;
    Label2: TLabel;
    LblActive: TLabel;
    EdNumTel: TEdit;
    BtnGoDisc: TButton;
    Label3: TLabel;
    LblMSgVocStatus: TLabel;
    EdConnString: TEdit;
    Label4: TLabel;
    EdDiscString: TEdit;
    Label5: TLabel;
    BtnGoPlay: TButton;
    ScrollBox1: TScrollBox;
    Memo1: TMemo;
    Label10: TLabel;
    TheMsgVoc: TMsgVoc;
    CBComPortNumber: TComboBox;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    MemoDTMF: TMemo;
    PanelTX: TPanel;
    BtnPlay: TButton;
    EdMsgVoc: TEdit;
    Label7: TLabel;
    Label9: TLabel;
    EdNRep: TEdit;
    Label14: TLabel;
    BtnGoEndTX: TButton;
    MemoInitModem: TMemo;
    PanelRX: TPanel;
    EdRecFile: TEdit;
    Label8: TLabel;
    BtnGoRec: TButton;
    BtnGoEndRec: TButton;
    BtnGoDialConn: TButton;
    BtnGoConn: TButton;
    procedure BtnGoInitClick(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure BtnGoDiscClick(Sender: TObject);
    procedure BtnGoPlayClick(Sender: TObject);
    procedure BtnGoRecClick(Sender: TObject);
    procedure BtnGoEndRecClick(Sender: TObject);
    procedure TheMsgVocDTMF(Sender: TObject; DTMF: Char);
    procedure BtnPlayClick(Sender: TObject);
    procedure BtnGoEndTXClick(Sender: TObject);
    procedure BtnGoDialConnClick(Sender: TObject);
    procedure BtnGoConnClick(Sender: TObject);
    procedure TheMsgVocRing(Sender: TObject);

  private
    { Private declarations }
    procedure EnableBtns;
  public
    { Public declarations }

  end;

var
  Form1: TForm1;

implementation


{$R *.DFM}

procedure TForm1.BtnGoInitClick(Sender: TObject);
var i : integer;
begin
     TheMSgVoc.ComPortNumber := TComPortNumber(CBComPortNumber.ItemIndex);
     TheMsgVoc.DialNum := EdNumTel.Text;
     TheMsgVoc.InitString := '';
     for i := 0 to MemoInitModem.Lines.Count - 1 do begin
          TheMsgVoc.InitString := TheMsgVoc.InitString + MemoInitModem.Lines[i];
     end;
     TheMsgVoc.ConnString := EdConnString.Text;
     TheMsgVoc.DiscString := EdDiscString.Text;
     TheMsgVoc.GoInit;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var sbp, i,ll, lm : Integer;
    sd : string;
begin
     // displays the Active caption
     LblCounter.Caption := inttostr(TheMsgVoc.CounterTime);
     if TheMsgVoc.Active then
        LblActive.Caption := 'True'
     else
        LblActive.Caption := 'False';
     LblMsgVocStatus.Caption := TheMsgVoc.GetStatusString;

     // updates the modem dialogue
     ll := length(TheMsgVoc.ModemDialog) - 1;
     lm := length(Memo1.Text) - 1;
     if lm > ll then lm:= ll; // take the shortest string
     if((lm<0) or (lm > 0) and (TheMSgVoc.ModemDialog[lm] <> Memo1.Text[lm])) then begin
           sd := '';
           for i:= 1 to ll do begin
               if TheMSgVoc.ModemDialog[i] <> chr(0) then
                   sd := sd + TheMsgVoc.ModemDialog[i]
               else
                   sd := sd + ' ';
           end;
           Memo1.Text := sd;
           sbp := Memo1.Lines.Count*13 - ScrollBox1.Height + 5;
           if(sbp>0) then
               ScrollBox1.VertScrollBar.Position := sbp;
     end;

     // enable or disable buttons depending on the status of TheMsgVoc
     EnableBtns;
end;


procedure TForm1.EnableBtns;
// enable or disable buttons depending on the status of TheMsgVoc
begin
     BtnGoInit.Enabled := False;
     BtnGoDialConn.Enabled := False;
     BtnGoConn.Enabled := False;
     BtnGoPlay.Enabled := False;
     BtnPlay.Enabled := False;
     BtnGoEndTX.Enabled := False;
     BtnGoRec.Enabled := False;
     BtnGoEndRec.Enabled := False;

     case TheMsgVoc.GetStatus of
        stDisc : begin
           BtnGoInit.Enabled := True;
        end;
        stInit : begin
           BtnGoDialConn.Enabled := True;
           BtnGoConn.Enabled := True;
        end;
        stConn : begin
           BtnGoPlay.Enabled := True;
           BtnGoRec.Enabled := True;
        end;
        stTX : begin
           BtnGoEndTX.Enabled := True;
           BtnPlay.Enabled := True;
           BtnPlay.Enabled := True;
        end;
        stRX : begin
           BtnGoEndRec.Enabled := True;
        end;
        else begin
        end;
     end;
end;


procedure TForm1.BtnGoDiscClick(Sender: TObject);
begin
     TheMSgVoc.ComPortNumber := TComPortNumber(CBComPortNumber.ItemIndex);
     TheMsgVoc.DialNum := EdNumTel.Text;
     TheMsgVoc.ConnString := EdConnString.Text;
     TheMsgVoc.DiscString := EdDiscString.Text;
     TheMsgVoc.GoDisc;
end;

procedure TForm1.BtnGoPlayClick(Sender: TObject);
begin
     TheMSgVoc.ComPortNumber := TComPortNumber(CBComPortNumber.ItemIndex);
     TheMsgVoc.DialNum := EdNumTel.Text;
     TheMsgVoc.ConnString := EdConnString.Text;
     TheMsgVoc.DiscString := EdDiscString.Text;
     TheMsgVoc.GoTX;
end;

procedure TForm1.BtnGoRecClick(Sender: TObject);
begin
     TheMSgVoc.ComPortNumber := TComPortNumber(CBComPortNumber.ItemIndex);
     TheMsgVoc.DialNum := EdNumTel.Text;
     TheMsgVoc.RecFile := EdRecFile.Text;
     TheMsgVoc.DiscString := EdDiscString.Text;
     TheMsgVoc.GoRX;
end;

procedure TForm1.BtnGoEndRecClick(Sender: TObject);
begin
     TheMsgVoc.GoEndRX;
end;

procedure TForm1.TheMsgVocDTMF(Sender: TObject; DTMF: Char);

begin
     MemoDTMF.Lines.Text := MemoDTMF.Lines.Text + DTMF + ' ' ;
end;

procedure TForm1.BtnPlayClick(Sender: TObject);
begin
     TheMsgVoc.Play(EdMsgVoc.Text, StrToInt(EdNRep.Text));
end;

procedure TForm1.BtnGoEndTXClick(Sender: TObject);
begin
     TheMsgVoc.GoEndTX;
end;



procedure TForm1.BtnGoDialConnClick(Sender: TObject);
begin
     TheMsgVoc.GoDialConn;
end;

procedure TForm1.BtnGoConnClick(Sender: TObject);
begin
     TheMsgVoc.GoConn;
end;

procedure TForm1.TheMsgVocRing(Sender: TObject);
begin
     MemoDTMF.Lines.Text := MemoDTMF.Lines.Text + 'RING ' ;
end;

end.

⌨️ 快捷键说明

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