Solved

"Control has no parent window" error message

Posted on 2000-03-18
7
1,534 Views
Last Modified: 2010-04-04
Dear friends,

I'm developing a new component herited from a TreeView. I use a small application to test it since the very beginning without problem.
Today, when I drop the component from the palette to a new form, I got this message. Can you help me ?

Bob
0
Comment
Question by:baudewyns
7 Comments
 
LVL 7

Expert Comment

by:ahalya
ID: 2632780
I think you can assign a parent in your control's create event;
e.g.
 
constructor TMyControl.Create(AOwner:TWinControl);

begin;
inherited Create;
Parent := AOwner;
....
0
 
LVL 1

Expert Comment

by:aldyn
ID: 2632798
Likely you trying to do some operations (painting or something else that requires control's window handle) before the parent is set. Delay it until the SetParent will be called.
0
 

Expert Comment

by:toesable
ID: 2632829
make sure you have this statement: inherited Create(AOwner); in your constructor.  
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:ITugay
ID: 2635194
Avoid drawing if Parent = nil.
0
 
LVL 2

Expert Comment

by:alexstewart@beta
ID: 2637881
Sounds like this is happening at design time.

try checking componentstate for csDesigning and that parent<>nil before doing stuff.

You might try removing and reinstalling the package too, since it might be 'stale' code (designtime<>runtime).

I sometimes override the paint method, to tell me when its ok to do stuff, I wait for the first call to paint.

Alex

0
 

Accepted Solution

by:
apostolost earned 50 total points
ID: 2639525
Hi All,

You need to override the GetOwner Function.

Cheers,

  ApostolosT.
0
 

Author Comment

by:baudewyns
ID: 2641577
Well, the problem is not coming from my Tree component but from the Header created by code which is a recent addition. If I remove this part of the code, it's working fine.

I have to look around to fix the bug.
Many thanks to all of you.

I accept the answer to close the file even if not really relevant.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
calling Tcolordialog in dll make the form disappear 8 103
Convert Jpg /PNG To GIF 5 118
How to debug For loops? 3 45
tvirtualstringtree freeze when load too manny images 10 52
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now