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

📄 eddial.pas

📁 利用TAPI实现对普通电话线路的控制。注意:需要使用支持TAPI的语音调制解调器。
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  skKey: Word;
begin
  ShortCutToKey(FButtonShortCut,skKey,skShift);

  if (Key=skKey) and (Shift=skShift) then
  begin
    { Shorcut}
    ButtonClick(Sender);
  end;

  if Assigned(FOnKeyDown) then
    FOnKeyDown(self,Key,Shift);
end;

procedure TCustomEditAndBtn.KeyPress(Sender: TObject; var Key: Char);
begin
  if Assigned(FOnKeyPress) then
    FOnKeyPress(self,Key);
end;

procedure TCustomEditAndBtn.KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if Assigned(FOnKeyUp) then
    FOnKeyUp(self,Key,Shift);
end;

procedure TCustomEditAndBtn.MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Assigned(FOnMouseDown) then
    FOnMouseDown(self,Button,Shift,X,Y);
end;

procedure TCustomEditAndBtn.MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  if Assigned(FOnMouseMove) then
    FOnMouseMove(self,Shift,X,Y);
end;

procedure TCustomEditAndBtn.MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Assigned(FOnMouseUp) then
    FOnMouseUp(self,Button,Shift,X,Y);
end;

procedure TCustomEditAndBtn.StartDrag(Sender: TObject; var DragObject: TDragObject);
begin
  if Assigned(FOnStartDrag) then
    FOnStartDrag(self,DragObject);
end;

procedure TCustomEditAndBtn.ButtonClick(Sender : TObject);
begin
  if Assigned(FOnButtonClick) then
    FOnButtonClick(self);
end;

procedure TCustomEditAndBtn.ButtonMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Assigned(FOnButtonMouseDown) then
    FOnButtonMouseDown(self,Button,Shift,X,Y);
end;

procedure TCustomEditAndBtn.ButtonMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  if Assigned(FOnButtonMouseMove) then
    FOnButtonMouseMove(self,Shift,X,Y);
end;

procedure TCustomEditAndBtn.ButtonMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Assigned(FOnButtonMouseUp) then
    FOnButtonMouseUp(self,Button,Shift,X,Y);
end;

destructor TCustomEditAndBtn.Destroy;
begin
  FEdit:=nil;
  FSpeedButton:=nil;

  inherited Destroy;
end;

procedure TCustomEditAndBtn.WMSize( var Message: TWMSize );
begin
  if Height<24 then Height:=24;
  FEdit.Top:=0;
  FEdit.Height:=Height;
  FEdit.Width:=Width-30;
  FEdit.Left:=0;
  FEdit.Refresh;

  FSpeedButton.Top:=0;
  FSpeedButton.Height:=Height;
  FSpeedButton.Width:=24;
  FSpeedButton.Left:=Width-24;

  FSpeedButton.Refresh;
end;


{ =================================== Property ===============================}

function TCustomEditAndBtn.GetButtonCaption: String;
begin
  result:=FSpeedButton.Caption;
end;

procedure TCustomEditAndBtn.SetButtonCaption(s: String);
begin
  FSpeedButton.Caption:=s;
end;

function TCustomEditAndBtn.GetButtonHint: String;
begin
  result:=FSpeedButton.Hint;
end;

procedure TCustomEditAndBtn.SetButtonHint(s: String);
begin
  FSpeedButton.Hint:=s;
end;

function TCustomEditAndBtn.GetTabStop: boolean;
begin
  result:=FEdit.TabStop;
end;

procedure TCustomEditAndBtn.SetTabStop(b: boolean);
begin
  FEdit.TabStop:=b;
end;

function TCustomEditAndBtn.GetText: String;
begin
  result:=FEdit.text;
end;

procedure TCustomEditAndBtn.SetText(s : String);
begin
  FEdit.text:=s;
end;

function TCustomEditAndBtn.GetAutoSelect : boolean;
begin
  result:=FEdit.AutoSelect;
end;

procedure TCustomEditAndBtn.SetAutoSelect(b : boolean);
begin
  FEdit.AutoSelect:=b;
end;

function TCustomEditAndBtn.GetDragCursor: TCursor;
begin
  result:=FEdit.DragCursor;
end;

procedure TCustomEditAndBtn.SetDragCursor(c: TCursor);
begin
  FEdit.DragCursor:=c;
end;

function TCustomEditAndBtn.GetDragMode: TDragMode;
begin
  result:=FEdit.DragMode;
end;

procedure TCustomEditAndBtn.SetDragMode(d: TDragMode);
begin
  FEdit.DragMode:=d;
end;

function TCustomEditAndBtn.GetCtl3d : boolean;
begin
  result:=FEdit.Ctl3d;
end;

procedure TCustomEditAndBtn.SetCtl3d(b : boolean);
begin
  FEdit.Ctl3d:=b;
end;

function TCustomEditAndBtn.GetGlyph: TBitmap;
begin
  result:=FSpeedButton.Glyph;
end;

procedure TCustomEditAndBtn.SetGlyph(b: TBitmap);
begin
  FSpeedButton.Glyph:=b;
end;

function TCustomEditAndBtn.GetNumGlyphs: TNumGlyphs;
begin
  result:=FSpeedButton.NumGlyphs;
end;

procedure TCustomEditAndBtn.SetNumGlyphs(n: TNumGlyphs);
begin
  FSpeedButton.NumGlyphs:=n;
end;

function TCustomEditAndBtn.GetHideSelection : boolean;
begin
  result:=FEdit.HideSelection;
end;

procedure TCustomEditAndBtn.SetHideSelection(b : boolean);
begin
  FEdit.HideSelection:=b;
end;

procedure TCustomEditAndBtn.SetMaxLength(i: integer);
begin
  FEdit.MaxLength:=i;
end;

function TCustomEditAndBtn.GetMaxLength : integer;
begin
  result:=FEdit.MaxLength;
end;

function TCustomEditAndBtn.GetOEMConvert: boolean;
begin
  result:=FEdit.OEMConvert;
end;

procedure TCustomEditAndBtn.SetOEMConvert(b: boolean);
begin
  FEdit.OEMConvert:=b;
end;

function TCustomEditAndBtn.GetParentColor: boolean;
begin
  result:=FEdit.ParentColor;
end;

procedure TCustomEditAndBtn.SetParentColor(b: boolean);
begin
  FEdit.ParentColor:=b;
end;

function TCustomEditAndBtn.GetParentCtl3D: boolean;
begin
  result:=FEdit.ParentCtl3D;
end;

procedure TCustomEditAndBtn.SetParentCtl3D(b: boolean);
begin
  FEdit.ParentCtl3D:=b;
end;

function TCustomEditAndBtn.GetParentFont: boolean;
begin
  result:=FEdit.ParentFont;
end;

procedure TCustomEditAndBtn.SetParentFont(b: boolean);
begin
  FEdit.ParentFont:=b;
  FSpeedButton.ParentFont:=b;
end;

function TCustomEditAndBtn.GetParentShowHint: boolean;
begin
  result:=FEdit.ParentShowHint;
end;

procedure TCustomEditAndBtn.SetParentShowHint(b: boolean);
begin
  FEdit.ParentShowHint:=b;
  FSpeedButton.ParentShowHint:=b;
end;

function TCustomEditAndBtn.GetPasswordChar: char;
begin
  result:=FEdit.PasswordChar;
end;

procedure TCustomEditAndBtn.SetPasswordChar(c: char);
begin
  FEdit.PasswordChar:=c;
end;

function TCustomEditAndBtn.GetReadOnly: boolean;
begin
  result:=FEdit.ReadOnly;
end;

procedure TCustomEditAndBtn.SetReadOnly(b: boolean);
begin
  FEdit.ReadOnly:=b;
end;

function TCustomEditAndBtn.GetShowHint : boolean;
begin
  result:=FEdit.ShowHint;
end;

procedure TCustomEditAndBtn.SetShowHint(b : boolean);
begin
  FSpeedButton.ShowHint:=b;
  FEdit.ShowHint:=b;
end;

function TCustomEditAndBtn.GetCharCase: TEditCharCase;
begin
  result:=FEdit.CharCase;
end;

procedure TCustomEditAndBtn.SetCharCase(c: TEditCharCase);
begin
  FEdit.CharCase:=c;
end;

function TCustomEditAndBtn.GetColor : TColor;
begin
  result:=FEdit.Color;
end;

procedure TCustomEditAndBtn.SetColor(c : TColor);
begin
  FEdit.Color:=c;
end;

procedure TCustomEditAndBtn.SetButtonEnabled(b : boolean);
begin
  FButtonEnabled:=b;
  FSpeedButton.Enabled:=b;
end;

function TCustomEditAndBtn.GetFont : TFont;
begin
  result:=FEdit.Font;
end;

procedure TCustomEditAndBtn.SetFont(f : TFont);
begin
  FEdit.Font:=f;
end;

function TCustomEditAndBtn.GetButtonVisible : boolean;
begin
  result:=FSpeedButton.Visible;
end;

procedure TCustomEditAndBtn.SetButtonVisible(b : boolean);
begin
  FSpeedButton.Visible:=b;
end;

procedure TCustomEditAndBtn.SetName(const NewName: TComponentName);
begin
  inherited SetName(NewName);

  if FEdit.Text='' then
  begin
    FEdit.Text:=NewName;
    FEdit.Refresh;
  end;
end;

{================================ TEditAndDial ===============================}

constructor TEditAndDial.Create( AOwner: TComponent );
begin
  inherited Create(AOwner);

  LoadDialBitmap;
  FButtonKind:=dkStandard;
  StrPCopy(FCalledParty,'');
end;

destructor TEditAndDial.Destroy;
begin

  inherited Destroy;
end;

procedure TEditAndDial.EvBeforeDial(Sender: TObject; var CalledParty: string);
begin
  CalledParty:='';
  if Assigned(FBeforeDial) then
    FBeforeDial(self, CalledParty);
end;

procedure TEditAndDial.LoadDialBitmap;
begin
  ButtonGlyph.Handle:=LoadBitmap(hInstance,'DIAL');
  ButtonNumGlyphs:=2;
end;

function TEditAndDial.GetKind: TEditAndDialBtnKind;
begin
  result:=FButtonKind;
end;

procedure TEditAndDial.SetKind(Value: TEditAndDialBtnKind);
begin
  if Value=dkStandard then
    LoadDialBitmap;

  FButtonKind:=Value;
end;

procedure TEditAndDial.ButtonClick(Sender : TObject);
var
  lResult: longint;
  PhoneNumber: array [0..255] of char;
  Called: array [0..255] of char;
  CalledParty: string;
begin
  inherited ButtonClick(Sender);

  evBeforeDial(Self,CalledParty);
  StrPCopy(PhoneNumber,Text);
  StrPCopy(Called,CalledParty);
  lResult:=tapiRequestMakeCall(PhoneNumber,'',Called,'');

  if Assigned(FOnButtonClick) then
    FOnButtonClick(self);
end;

function TEditAndDial.GetGlyph: TBitmap;
begin
  result:=ButtonGlyph;
end;

procedure TEditAndDial.SetGlyph(b: TBitmap);
begin
  ButtonGlyph:=b;
  SetKind(dkCustom);
end;

procedure Register;
begin
  RegisterComponents('Supplement', [TEditAndBtn, TEditAndDial]);
end;

end.

⌨️ 快捷键说明

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