 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Olivier Zegeling Guest
|
Posted: Tue Oct 07, 2003 9:29 am Post subject: how to implement a component as a property and use its event |
|
|
I have written a component that handles TAPI events (Windows Telephony API).
Among other things this component fires a ringback event when an outgoing
call is established and is ringing.
Now I am tyriing to write some controls for this component. E.g. a memo that
displays all events from the TAPI component. Like Data Controls, my control
should be able to be linked to any TAPIComp on my form.
I have succeeded in making the TAPI component a property of the this memo
Control. Now I would like to attach a handles of the TAPIMemo to the events
triggered by TAPIComp. Can someone help?
type
TCallRingbackEvent = procedure(const CallReference:integer; DialedNumber:
String) of object;
type
TTapiComp = class(TComponent)
private
FOnRingBack:TCallRingbackEvent;
published
property OnRingBack: TCallRingbackEvent read FOnRingBack write
FOnRingBack;
end;
type
TTAPIMemo = class(TCustomMemo)
private
FTAPIComp: TTAPIComp;
public
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property TAPIComp:TTAPIComp read FTAPIComp write FTAPIComp;
end;
constructor TTAPIMemo.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FixedCols:=0;
ColCount:=7;
Cells[0,0]:='LineRef';
Cells[1,0]:='LineName';
Cells[2,0]:='CallRef';
Cells[3,0]:='DNI';
Cells[4,0]:='CLI';
Cells[5,0]:='RED';
Cells[6,0]:='Status';
DefaultRowHeight:=18;
DefaultColWidth:=100;
Width:=710;
end;
destructor TTAPIMemo.Destroy;
begin
inherited Destroy;
end;
procedure TTAPIMemo.Notification(AComponent: TComponent; Operation:
TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FTAPIComp) then
FTAPIComp := nil;
end;
|
|
| Back to top |
|
 |
WPA van Deursen Guest
|
Posted: Tue Oct 07, 2003 9:48 am Post subject: Re: how to implement a component as a property and use its e |
|
|
Add the function to be called to your TMemo definition and link it to
the event of the TTAPIComponent.
Something like
type
TTAPIMemo = class(TCustomMemo)
private
FTAPIComp: TTAPIComp;
public
// Two new procedures
procedure MyTAPICallRingBack(const CallReference:integer;
DialedNumber:String);
procedure SetTApIComp(Value:TTAPIComp);
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property TAPIComp:TTAPIComp read FTAPIComp write SetTAPIComp;
end;
procedure TTAPIMemo.SetTAPIComp(Value:TTAPIComp);
begin
FTAPIComp:=Value;
FTAPIComp.OnRingBack:=MyTAPICallRingBack;
end;
procedure TTAPIMemo.MyTAPICallRingBack(const CallReference:integer;
DialedNumber:String);
begin
// procedure is now called by every TTAPIComp CallRingBack event.
end;
(Obviously pseudo code, so not tested...)
Willem
Olivier Zegeling wrote:
| Quote: | I have written a component that handles TAPI events (Windows Telephony API).
Among other things this component fires a ringback event when an outgoing
call is established and is ringing.
Now I am tyriing to write some controls for this component. E.g. a memo that
displays all events from the TAPI component. Like Data Controls, my control
should be able to be linked to any TAPIComp on my form.
I have succeeded in making the TAPI component a property of the this memo
Control. Now I would like to attach a handles of the TAPIMemo to the events
triggered by TAPIComp. Can someone help?
type
TCallRingbackEvent = procedure(const CallReference:integer; DialedNumber:
String) of object;
type
TTapiComp = class(TComponent)
private
FOnRingBack:TCallRingbackEvent;
published
property OnRingBack: TCallRingbackEvent read FOnRingBack write
FOnRingBack;
end;
type
TTAPIMemo = class(TCustomMemo)
private
FTAPIComp: TTAPIComp;
public
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property TAPIComp:TTAPIComp read FTAPIComp write FTAPIComp;
end;
constructor TTAPIMemo.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FixedCols:=0;
ColCount:=7;
Cells[0,0]:='LineRef';
Cells[1,0]:='LineName';
Cells[2,0]:='CallRef';
Cells[3,0]:='DNI';
Cells[4,0]:='CLI';
Cells[5,0]:='RED';
Cells[6,0]:='Status';
DefaultRowHeight:=18;
DefaultColWidth:=100;
Width:=710;
end;
destructor TTAPIMemo.Destroy;
begin
inherited Destroy;
end;
procedure TTAPIMemo.Notification(AComponent: TComponent; Operation:
TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FTAPIComp) then
FTAPIComp := nil;
end;
|
--
Willem van Deursen
The Netherlands
[email]wvandeursen_nospam (AT) nospam_carthago (DOT) nl[/email]
replace _nospam@nospam_ for @ to get a valid email address
|
|
| Back to top |
|
 |
Olivier Zegeling Guest
|
Posted: Tue Oct 07, 2003 9:59 am Post subject: Re: how to implement a component as a property and use its e |
|
|
worked like a charm, tx.
"WPA van Deursen" <wvandeursen_nospam (AT) nospam_carthago (DOT) nl> wrote
| Quote: | Add the function to be called to your TMemo definition and link it to
the event of the TTAPIComponent.
Something like
type
TTAPIMemo = class(TCustomMemo)
private
FTAPIComp: TTAPIComp;
public
// Two new procedures
procedure MyTAPICallRingBack(const CallReference:integer;
DialedNumber:String);
procedure SetTApIComp(Value:TTAPIComp);
procedure Notification(AComponent: TComponent; Operation:
TOperation);
override;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property TAPIComp:TTAPIComp read FTAPIComp write SetTAPIComp;
end;
procedure TTAPIMemo.SetTAPIComp(Value:TTAPIComp);
begin
FTAPIComp:=Value;
FTAPIComp.OnRingBack:=MyTAPICallRingBack;
end;
procedure TTAPIMemo.MyTAPICallRingBack(const CallReference:integer;
DialedNumber:String);
begin
// procedure is now called by every TTAPIComp CallRingBack event.
end;
(Obviously pseudo code, so not tested...)
Willem
Olivier Zegeling wrote:
I have written a component that handles TAPI events (Windows Telephony
API).
Among other things this component fires a ringback event when an
outgoing
call is established and is ringing.
Now I am tyriing to write some controls for this component. E.g. a memo
that
displays all events from the TAPI component. Like Data Controls, my
control
should be able to be linked to any TAPIComp on my form.
I have succeeded in making the TAPI component a property of the this
memo
Control. Now I would like to attach a handles of the TAPIMemo to the
events
triggered by TAPIComp. Can someone help?
type
TCallRingbackEvent = procedure(const CallReference:integer;
DialedNumber:
String) of object;
type
TTapiComp = class(TComponent)
private
FOnRingBack:TCallRingbackEvent;
published
property OnRingBack: TCallRingbackEvent read FOnRingBack write
FOnRingBack;
end;
type
TTAPIMemo = class(TCustomMemo)
private
FTAPIComp: TTAPIComp;
public
procedure Notification(AComponent: TComponent; Operation:
TOperation);
override;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property TAPIComp:TTAPIComp read FTAPIComp write FTAPIComp;
end;
constructor TTAPIMemo.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FixedCols:=0;
ColCount:=7;
Cells[0,0]:='LineRef';
Cells[1,0]:='LineName';
Cells[2,0]:='CallRef';
Cells[3,0]:='DNI';
Cells[4,0]:='CLI';
Cells[5,0]:='RED';
Cells[6,0]:='Status';
DefaultRowHeight:=18;
DefaultColWidth:=100;
Width:=710;
end;
destructor TTAPIMemo.Destroy;
begin
inherited Destroy;
end;
procedure TTAPIMemo.Notification(AComponent: TComponent; Operation:
TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FTAPIComp) then
FTAPIComp := nil;
end;
--
Willem van Deursen
The Netherlands
[email]wvandeursen_nospam (AT) nospam_carthago (DOT) nl[/email]
replace _nospam@nospam_ for @ to get a valid email address
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|