Board index » delphi » Control has no parent window

Control has no parent window

When I try to execute the following procedure I get a error saying "Control"
has no parent window. SortGrid is a decendent of StringGrid if it helps.
I understand that the SortGrid I create doesn't have a parent. I just don't
now how to supply it with a parent. Any help? Pretty please :)

procedure TForm1.Button1Click(Sender: TObject);
var
  SortGrid: TSortGrid;
begin
  SortGrid := TSortGrid.Create(self);
  SortGrid.LoadFromFile('hitdr.txt', #9);
  SortGrid.AutoSizeColumns(true, 0);

end;

 

Re:Control has no parent window


sortgrid.parent:=form1 ?
(after the tsortgrid.create(self) line)

Nick

Quote
"Mogens Andersen" <moge...@NOofirSPAM.dk> wrote in message

news:9W%w8.2014$HZ2.139657@news000.worldonline.dk...
Quote
> When I try to execute the following procedure I get a error saying
"Control"
> has no parent window. SortGrid is a decendent of StringGrid if it helps.
> I understand that the SortGrid I create doesn't have a parent. I just
don't
> now how to supply it with a parent. Any help? Pretty please :)

> procedure TForm1.Button1Click(Sender: TObject);
> var
>   SortGrid: TSortGrid;
> begin
>   SortGrid := TSortGrid.Create(self);
>   SortGrid.LoadFromFile('hitdr.txt', #9);
>   SortGrid.AutoSizeColumns(true, 0);

> end;

Re:Control has no parent window


Quote
"Nicholas Sherlock" <n_sherl...@hotmail.com> wrote in message

news:aa2ag5$a98$1@lust.ihug.co.nz...

Quote
> sortgrid.parent:=form1 ?
> (after the tsortgrid.create(self) line)

What if I plan to use this component in a console application. How would I
then go about it?

Re:Control has no parent window


In article <aa2ag5$a9...@lust.ihug.co.nz>, "Nicholas Sherlock"

Quote
<n_sherl...@hotmail.com> writes:
>sortgrid.parent:=form1 ?
>(after the tsortgrid.create(self) line)

No - better code is ...

SortGrid.Parent := Self;

In general, class code should not refer to specific instances of the class
you're coding for. If you have only one instance it may not matter but if you
had more than one it certainly would, and its never too early to inculcate good
practices <g>.

Parent is the object your new object is visually aligned to. And the object
which passes windows messages on to your new object.

Owner is the object which releases memory (ie calls Free) for your new object.
If you specify nil then you must do that. If you do call Free, then you should
set your object's reference to nil if the scope of your object reference is
global.

Alan Lloyd
alangll...@aol.com

Re:Control has no parent window


On Tue, 23 Apr 2002 07:57:33 +0200, "Mogens Andersen"

Quote
<moge...@NOofirSPAM.dk> wrote:

>"Nicholas Sherlock" <n_sherl...@hotmail.com> wrote in message
>news:aa2ag5$a98$1@lust.ihug.co.nz...
>> sortgrid.parent:=form1 ?
>> (after the tsortgrid.create(self) line)

>What if I plan to use this component in a console application. How would I
>then go about it?

What is TSortGrid ?

- I don't have it in D4P

It sounds like a Display Component

- you would not by any chance be using a component as an easy way of
sorting data ...

Not really a very good idea - especially in a Console App

Quote

Other Threads