Link to home
Start Free TrialLog in
Avatar of rene100
rene100

asked on

New Component

Hi all

i've a problem with creating a new component:
I want to write a ComboBox that filles in all avaible
fonts automatical. her's what I done:

unit FontComboBox;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TFontComboBox = class(TComboBox)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    constructor Create(AOwner: TComponent);override;
    { Public declarations }
  published
    procedure UpdateFonts;
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Eigene', [TFontComboBox]);
end;

constructor TFontComboBox.Create(AOwner: TComponent);
begin
Inherited Create(AOwner);
UpdateFonts;
end;

procedure TFontComboBox.UpdateFonts;
var
Index: integer;
begin
Clear; <-- Error here
For Index:=0 to Screen.Fonts.Count-1 do
    Items.Add(Screen.Fonts[Index]);
end;
end.

But everytime I create my new component in desgin-time
(I mean by dragging it on a form) or manipulating the items-property at runtime, I get the error-mesage:" Control '' has no parent window"

What's wrong?

regards
rene
ASKER CERTIFIED SOLUTION
Avatar of inter
inter
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rene100
rene100

ASKER

Ok, it works fine
Thanks a lot!

regards
rene