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
Solved

New Component

Posted on 1998-10-30
2
168 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 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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