Board index » cppbuilder » TFrame at run time exception

TFrame at run time exception


2003-08-11 07:08:19 PM
cppbuilder21
I create a TFrame with a TCombobox inside.
If combo Items is not null at runtime when i create frame i have an exception : "control xxx has no parent window".
How i can set the parent property if frame brake on constructor?
Thanks
Francecsco.
 
 

Re:TFrame at run time exception

"Francesco" < XXXX@XXXXX.COM >wrote in message
Quote
If combo Items is not null at runtime when i create frame
i have an exception : "control xxx has no parent window".
That error occurs when you try to use a property that is dependant on a
valid Parent bewing assigned but the Parent has not actually been assigned
yet.
Please show your actual code.
Quote
How i can set the parent property if frame brake on constructor?
The Parent of the combobox or the frame itself? Please be more specifc.
Gambit
 

Re:TFrame at run time exception

I solve the probem by override CreateWnd function, this is the code i put on frame created :
void __fastcall TFrame1::CreateWnd(void)
{
if (!HasParent())
Parent = dynamic_cast<TWinControl *>(Owner);
TFrame::CreateWnd();
}
Thanks
Francecsco.
"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote

"Francesco" < XXXX@XXXXX.COM >wrote in message
news:3f377923$ XXXX@XXXXX.COM ...

>If combo Items is not null at runtime when i create frame
>i have an exception : "control xxx has no parent window".

That error occurs when you try to use a property that is dependant on a
valid Parent bewing assigned but the Parent has not actually been assigned
yet.

Please show your actual code.

>How i can set the parent property if frame brake on constructor?

The Parent of the combobox or the frame itself? Please be more specifc.


Gambit


 

{smallsort}

Re:TFrame at run time exception

I'm picking this up, as Francesco is on holiday.
Remy Lebeau (TeamB) wrote:
Quote
"Francesco" < XXXX@XXXXX.COM >wrote in message
news:3f377923$ XXXX@XXXXX.COM ...

>If combo Items is not null at runtime when i create frame
>i have an exception : "control xxx has no parent window".

That error occurs when you try to use a property that is dependant on a
valid Parent bewing assigned but the Parent has not actually been assigned
yet.

Please show your actual code.
I'm trying to isolate the problem, but it's not easy to pinpoint. We
have several frames which we want to instantiate at runtime and display
in a TPageControl. These frames have a similar structure; they all
inherit from the same hyerarchy:
class TTreePageFrame : public TFrame;
This is stored in a first package and holds code to handle which pages
are visible in the TPageControl.
class TFrameWP : public TTreePageFrame;
This is stored in a second package and handles common visual aspects:
color, font, etc.
All the descendent frames, which we are trying to instantiate at
runtime, are stored in a third package. Each of these contain at least
one additional frame. When this inner frame contains a TComboBox whose
Items property is set at design time, we experience the problem
Francesco describes.
Quote
>How i can set the parent property if frame brake on constructor?

The Parent of the combobox or the frame itself? Please be more specifc.
Francesco refers to the Frame parent property. The point is that there's
no way to set both owner and parent when we instantiate a Frame:
TMyFrame * f = new TMyFrame(owner);
The application crashes before we can do
f->Parent = whatever;
Cheers,
--
Nicola Musatti
Team Thai Kingdom