Solved

"Control has no parent window" error message

Posted on 2000-03-18
7
1,668 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
[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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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