Re: Owner Draw of ComboBox Text & Items

From: AlanGLLoyd (alanglloyd_at_aol.com)
Date: 11/22/03


Date: 22 Nov 2003 22:26:27 GMT

I am having problems adding the TEditListBox to the component palette. The code
compiles and runs fine as a separate unit in an application which uses it. I
then attemptd to add it to the component palette, and it appeared to compile OK
into DCLUser30. And it appeared OK on a page of the component.

When I tried to use it, not only did the TEditListBox appear on the form, but
also the default component icon in a panel as though the component was a
non-visual component. Then when I tried to compile the form it had error
messages saying that it could not find the TEdit, the TBitBtn, and the TListBox
classes. Until I added one of each of these components from the default
component palette pages, it would not compile. The Object inspector also showed
one of these components but un-named, as well as a page for the TEditListBox.

Class declaration of the TEditListBox class is as follows :

  TEditListBox = class(TComponent)
    Edit: TEdit;
    BitBtn: TBitBtn;
    ListBox: TListBox;
  private
    { Private declarations }
    FLeft : integer;
    FTop : integer;
    FEditFontColor : TColor;
    FListFontColor : TColor;
    FParent : TWinControl;
    procedure BitBtnClick(Sender: TObject);
    procedure EditChange(Sender: TObject);
    function GetItem(Index : Integer) : string;
    function GetItems : TStrings;
    function GetParent : TWinControl;
    procedure ListBoxClick(Sender: TObject);
    procedure SetEditFontColor(AValue : TColor);
    procedure SetItem(Index : integer; AValue : string);
    procedure SetItems(AValue : TStrings);
    procedure SetLeft(AValue : integer);
    procedure SetListFontColor(AValue : TColor);
    procedure SetParent(AValue : TWinControl);
    procedure SetTop(AValue : integer);
  public
    { Public declarations }
    constructor Create(AOwner : TComponent); override;
    destructor Destroy; override;
    property EditFontColor : TColor read FEditFontColor write SetEditFontColor;
    property Item[Index : integer] : string read GetItem write SetItem;
    property ListFontColor : TColor write SetListFontColor;
    property Parent : TWinControl read GetParent write SetParent;
  published
    property Items : TStrings read GetItems write SetItems;
    property Left : integer read FLeft write SetLeft;
    property Top : integer read FTop write SetTop;
  end;

All units for the TEdit, TBitBtn and TListBox objects are in the interface uses
clause.

Any suggestions please.

Alan Lloyd
alanglloyd@aol.com