来电管理的开发控件TeleComport |
chen在2007/5/21发表,被浏览8784次
|
适合对象:Delphi 使用方法: 一、DELPHI 6 用户 (1) 下载控件包Component.rar(在会员下载中) (2) 先编译 CPortLib6.dpk ,已安装了CPortLib 控件组的可省略这一步骤 (3) 然后编译 TelePort.dpk ,并安装 (4) 安装完成后,在 kosenTools 控件页增加了一个控件:TeleComport (5) 使用示例请看 Project2.dpr
二、DELPHI 7 用户 (1) 下载控件包 Component_D7.RAR (2) 先编译TelePort.dpk ,并安装 (3) 安装完成后,在 kosenTools 控件页增加了一个控件:TeleComport (4) 使用示例请看 Project2.dpr
示例源程序
unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CPort, TeleComportUnit; type TForm1 = class(TForm) TeleComport1: TTeleComport; Memo1: TMemo; Button1: TButton; Button2: TButton; Button3: TButton; procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure TeleComport1Open(Sender: TObject); procedure TeleComport1Close(Sender: TObject); procedure TeleComport1Read(Sender: TObject; s: String; t: TDateTime); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button2Click(Sender: TObject); begin if TeleComport1.SetupPort then Memo1.Lines.Add('Port='+TeleComport1.Port); //设置来电管理器的连接端口,USB端口的设置为Port:="USB" end; procedure TForm1.Button1Click(Sender: TObject); begin TeleComport1.Open; end; procedure TForm1.Button3Click(Sender: TObject); begin TeleComport1.Close; end; procedure TForm1.TeleComport1Open(Sender: TObject); begin if TeleComport1.JDConnected then begin Memo1.Lines.Add('Connected'); //打开端口时读取来电管理器内缓存的号码 TeleComport1.ReadAllWhenOpen; end; end; procedure TForm1.TeleComport1Close(Sender: TObject); begin if not TeleComport1.JDConnected then Memo1.Lines.Add('not Connected'); end; //有来电时触发此事件 //s为来电号码,t为来电时间 procedure TForm1.TeleComport1Read(Sender: TObject; s: String; t: TDateTime); begin Memo1.Lines.Add(s+FormatDateTime(' yyyy-mm-dd hh:nn:ss', t)); end; end.
object Form1: TForm1 Left = 548 Top = 285 Width = 394 Height = 295 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object Memo1: TMemo Left = 0 Top = 0 Width = 273 Height = 261 Align = alLeft TabOrder = 0 end object Button1: TButton Left = 280 Top = 48 Width = 100 Height = 25 Caption = '打开' TabOrder = 1 OnClick = Button1Click end object Button2: TButton Left = 280 Top = 8 Width = 100 Height = 25 Caption = '端口设置' TabOrder = 2 OnClick = Button2Click end object Button3: TButton Left = 280 Top = 88 Width = 100 Height = 25 Caption = '关闭' TabOrder = 3 OnClick = Button3Click end object TeleComport1: TTeleComport BaudRate = br9600 Port = 'COM1' Parity.Bits = prNone StopBits = sbOneStopBit DataBits = dbEight OnOpen = TeleComport1Open OnClose = TeleComport1Close OnRead = TeleComport1Read JDConnected = False Left = 56 Top = 32 end end
|
|
|
|