Solved

"Control has no parent window" error message

Posted on 2000-03-18
7
1,566 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

832 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