Solved

New Component

Posted on 1998-10-30
2
172 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:rene100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
inter earned 100 total points
ID: 1345022
The problem is that the inherited Create cannot create the owner windows before exiting the FontCombos Create to solve the problem

1 - Remove UpdateFonts from your Create Method
2 - add the following to your protected declerations

protected
  procedure CreateWnd;override;

3 - add the following to your unit body

procedure TFontComboBox.CreateWnd;
begin
  inherited CreateWnd;
  UpdateFonts;
end;

regards, igor
0
 
LVL 2

Author Comment

by:rene100
ID: 1345023
Ok, it works fine
Thanks a lot!

regards
rene
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month7 days, 7 hours left to enroll

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question