Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

New Component

Posted on 1998-10-30
2
Medium Priority
?
179 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
2 Comments
 
LVL 5

Accepted Solution

by:
inter earned 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

972 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