Hi folks,
I'm trying to create and use an offscreen TRichViewEdit and TRVStyle, within another class that isn't linked to a form. This is the initialization code:
FRVE := TRichViewEdit.Create(nil);
FRVE.Parent := TWinControl(Application.MainForm);
FRVS := TRVStyle.Create(nil);
"Control has no parent window" message
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
That message was incomplete for some reason, even though I typed it all!
I've also tried lots of other variations, using the Application.MainForm as owner as well as parent, and casting it or not casting it to TComponent (for owner) and TWinControl (for parent). In all cases, I get the dreaded "Control has no parent window" error.
Can anyone see what the problem might be, or suggest a solution?
All help appreciated,
Martin
I've also tried lots of other variations, using the Application.MainForm as owner as well as parent, and casting it or not casting it to TComponent (for owner) and TWinControl (for parent). In all cases, I get the dreaded "Control has no parent window" error.
Can anyone see what the problem might be, or suggest a solution?
All help appreciated,
Martin
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
FYI : I think I have had a similar problem once, and solved it (without analysing that in depth, actually) by moving the RV setup code from the initialization section to some form startup event, where the form already exists. It seems that it is required by RV, when creating the RVE or maybe when assigning the RVStyle ...
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
That could be it! I have a form which creates an object which, oncreate, creates another object which, oncreate, creates the RVE and the RVStyle. It's very possible that the main form hasn't finished being instantiated when its reference is being passed in to create the RVE and RVS.
I'll check that out. Thanks indeed for the suggestion; it hadn't occurred to me that the main form might not actually be there!
Cheers,
Martin
I'll check that out. Thanks indeed for the suggestion; it hadn't occurred to me that the main form might not actually be there!
Cheers,
Martin
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
That was it!
I was creating one of the objects during the Create event of the main form. At that point, the main form has presumably not finished being instantiated, and although no error was raised when the object was created, as soon as I tried to use it, the error appeared.
Many thanks indeed for your help.
Martin
I was creating one of the objects during the Create event of the main form. At that point, the main form has presumably not finished being instantiated, and although no error was raised when the object was created, as soon as I tried to use it, the error appeared.
Many thanks indeed for your help.
Martin