Subject | Re: [IBO] Help with Descending from TIB_CustomCombo |
---|---|
Author | Paul Vinkenoog |
Post date | 2004-01-20T11:34:12Z |
Hi Mark,
implementation for TIB_LookupCombo and TIB_LookupComboLink? (But with
different names for both.)
logic correctly. Or - in the case you didn't copy the interface from
TIB_LookupCombo - maybe you haven't published the necessary properties.
I can't tell exactly what happens here, but as a general advice: if
you want to mimic another component almost exactly and only change a
couple of things, don't descend from that component's ancestor, but
from the component itself, and override the methods you want to
implement differently:
interface
TIB_LookupComboB = class( TIB_LookupCombo )
protected
procedure KeyPress(var Key: Char); override;
...
...
end;
...
implementation
procedure TIB_CustomCombo.KeyPress( var Key: Char);
begin
...
...
end;
An additional benefit of this approach (apart from saving you
headaches) is that you can now use a TIB_LookupComboB anyplace a
TIB_LookupCombo is expected.
Like they said in the Borland manuals long ago: Don't reinvent the
wheel - inherit it!
Greetings,
Paul Vinkenoog
> I'm wanting to create my own Lookup combo that simply changes someWhen you say "listing", do you mean the entire interface and
> behaviour in the KeyPress method.
> I've created a new component descending from TIB_CustomCombo, just
> as TIB_LookupCombo does. eg.
> TIB_LookupComboB = class(TIB_CustomCombo)
>
> As a simple test, I copied and pasted the listing for
> TIB_LookupCombo. After adding in the two defines:
> {$DEFINE IBG_CustomGrid}
> {$DEFINE IBG_LookupCombo}
> The component compiles.
implementation for TIB_LookupCombo and TIB_LookupComboLink? (But with
different names for both.)
> HOWEVER...if I override the KeyPress method and simple re-implement"DataLink" is a TIB_LookupComboLink. Maybe you haven't copied all the
> (copy/paste from TIB_LookupCombo) an identical method, I get about
> 27 errors! All of the errors seem to be relating to undefined
> properties, such as DataLink (from PopupList.DataLink) and BDataset
> (I'm guessing it too is from the PopupList).
logic correctly. Or - in the case you didn't copy the interface from
TIB_LookupCombo - maybe you haven't published the necessary properties.
I can't tell exactly what happens here, but as a general advice: if
you want to mimic another component almost exactly and only change a
couple of things, don't descend from that component's ancestor, but
from the component itself, and override the methods you want to
implement differently:
interface
TIB_LookupComboB = class( TIB_LookupCombo )
protected
procedure KeyPress(var Key: Char); override;
...
...
end;
...
implementation
procedure TIB_CustomCombo.KeyPress( var Key: Char);
begin
...
...
end;
An additional benefit of this approach (apart from saving you
headaches) is that you can now use a TIB_LookupComboB anyplace a
TIB_LookupCombo is expected.
Like they said in the Borland manuals long ago: Don't reinvent the
wheel - inherit it!
Greetings,
Paul Vinkenoog