Board index » cppbuilder » Control '....' has no parent window

Control '....' has no parent window

I am writing some compnents...
For one of this, at design time, I receive this error from the IDE:
    Control '.....' has no parent window
I can't understand why! Do you have any idea? I checked my code but I can't
figure the problem - more over putting the control in Form using Text mode
sometimes works!!!

Other question: it is possible to have the property BorderStyle for
TComboBox as in TEdit?

thanks, Paolo

 

Re:Control '....' has no parent window


Paolo Casagrande <neme...@intelly.com> schrieb in im Newsbeitrag:
3c146c75$1_1@dnews...

Quote
> I am writing some compnents...
> For one of this, at design time, I receive this error from the IDE:
>     Control '.....' has no parent window
> I can't understand why! Do you have any idea? I checked my code but I
can't
> figure the problem - more over putting the control in Form using Text mode
> sometimes works!!!

> Other question: it is possible to have the property BorderStyle for
> TComboBox as in TEdit?

> thanks, Paolo

From which component are you inheriting? This error often occurs if you set
'visual' properties in the constructor of your component. The problem is
that the constructor is processed before the form is visible. Clear is one
candidate for this error in TComboBox( if I remember correctly).

Re:Control '....' has no parent window


"Paolo Casagrande" <neme...@intelly.com> schrieb im Newsbeitrag
news:3c16286b$1_1@dnews...

Quote

> "Paul Ashton" <asht...@worldonline.de> ha scritto nel messaggio
> news:3c1544d3$1_1@dnews...

What do :

void __fastcall DataChange(TObject* Sender);
void __fastcall UpdateData(TObject * Sender);

look like.

Re:Control '....' has no parent window


"Paul Ashton" <asht...@worldonline.de> ha scritto nel messaggio
news:3c1544d3$1_1@dnews...

Quote

> Paolo Casagrande <neme...@intelly.com> schrieb in im Newsbeitrag:
> 3c146c75$1_1@dnews...
> > I am writing some compnents...
> > For one of this, at design time, I receive this error from the IDE:
> >     Control '.....' has no parent window
> > I can't understand why! Do you have any idea? I checked my code but I
> can't
> > figure the problem - more over putting the control in Form using Text
mode
> > sometimes works!!!

> > Other question: it is possible to have the property BorderStyle for
> > TComboBox as in TEdit?

> > thanks, Paolo

> From which component are you inheriting? This error often occurs if you
set
> 'visual' properties in the constructor of your component. The problem is
> that the constructor is processed before the form is visible. Clear is one
> candidate for this error in TComboBox( if I remember correctly).

from TMaskEdit, making a DB component. I check the constructor but nothing
is 'visual', as you can see...

.h file

class PACKAGE TxDBMaskEdit : public TCustomMaskEdit
{
private:
    TFieldDataLink* FDataLink;

    AnsiString __fastcall GetDataField();
    void __fastcall SetDataField(AnsiString value);
    TDataSource* __fastcall GetDataSource();
    void __fastcall SetDataSource(TDataSource* value);

    void __fastcall DataChange(TObject* Sender);
    void __fastcall UpdateData(TObject * Sender);

    void __fastcall CMExit(TWMNoParams Message);

    BEGIN_MESSAGE_MAP
        MESSAGE_HANDLER(CM_EXIT, TWMNoParams, CMExit)
    END_MESSAGE_MAP(TCustomMaskEdit)
protected:
    DYNAMIC void __fastcall Change(void);
public:
    __fastcall TxDBMaskEdit(TComponent* Owner);
    __fastcall ~TxDBMaskEdit(void);

    __published:
    __property AnsiString DataField  = { read=GetDataField,
write=SetDataField };
    __property TDataSource* DataSource  = { read=GetDataSource,
write=SetDataSource };

    __property BorderStyle;
    __property EditMask;

Quote
};

.cpp file:

...

__fastcall TxDBMaskEdit::TxDBMaskEdit(TComponent* Owner)
    : TCustomMaskEdit(Owner)
{
    FDataLink = new TFieldDataLink();
    FDataLink->Control = this;
    FDataLink->OnDataChange = DataChange;
    FDataLink->OnUpdateData = UpdateData;

Quote
}

__fastcall TxDBMaskEdit::~TxDBMaskEdit(void)
{
    if (FDataLink) {
        FDataLink->OnUpdateData = 0;
        FDataLink->OnDataChange = 0;
        FDataLink->Control = 0;
        delete FDataLink;
    }

- Show quoted text -

Quote
}

Re:Control '....' has no parent window


Hello Paolo,

"Paolo Casagrande" <neme...@intelly.com> schreef in bericht
news:3c146c75$1_1@dnews...

Quote
> I am writing some compnents...
> For one of this, at design time, I receive this error from the IDE:
>     Control '.....' has no parent window

Hmm, this is a typical error that often can occur in aggregated components
when you start setting properties of an included component in the new
component constructor. It means that some properties you set need a handle,
but it isn't created yet...

If this is the case you need to override the TControl::CreateWnd() function
and do your property settings after that like:

// in header
class TMyComp : ParentComp {
    ....
protected:
    virtual void __fastcall CreateWnd();
    ...

Quote
};

// in source
void __fastcall TMyComp::CreateWnd()
{
    ParentComp::CreateWnd();
    // now the handle is there, do your settings

Quote
}
> thanks, Paolo

Hope this solves your problem...;-))

--
Greetings from overcast Amsterdam

         Jan

email: bijs...@worldonline.nl
http://home.worldonline.nl/~bijster

Re:Control '....' has no parent window


"Paul Ashton" <paul.ash...@admin-itc.de> ha scritto nel messaggio
news:3c162a91$1_1@dnews...

Quote

> "Paolo Casagrande" <neme...@intelly.com> schrieb im Newsbeitrag
> news:3c16286b$1_1@dnews...

> > "Paul Ashton" <asht...@worldonline.de> ha scritto nel messaggio
> > news:3c1544d3$1_1@dnews...

> What do :

> void __fastcall DataChange(TObject* Sender);
> void __fastcall UpdateData(TObject * Sender);

> look like.

Sorry, but I can't understand...
a similar code, for a component inherited from TComboBox work fine...

bye, Paolo

Re:Control '....' has no parent window


Hi, Paolo!

I think the following in your constructor will help take care of the
problem...

Parent = dynamic_cast<TWinControl *>(Owner);

Some properties when set require the control to have been parented, but
parenting normally doesn't occur until some time after the control has
been instantiated.

 ------
Mark Cashman (TeamB - C++ Builder), creator of The Temp{*word*203}Doorway at http://www.temporaldoorway.com
(original digital art, writing, music and more)
C++ Builder / JBuilder Tips and The C++ Builder Programmer's Webring (Join us!)
http://www.temporaldoorway.com/programming/index.htm
------

Re:Control '....' has no parent window


thanks a lot... it work fine!
Nice holiday to all
    Paolo

"Mark Cashman" <mcash...@temporaldoorway.com> ha scritto nel messaggio
news:3C22AEB0.5050801@temporaldoorway.com...

Quote
> Hi, Paolo!

> I think the following in your constructor will help take care of the
> problem...

> Parent = dynamic_cast<TWinControl *>(Owner);

> Some properties when set require the control to have been parented, but
> parenting normally doesn't occur until some time after the control has
> been instantiated.

>  ------
> Mark Cashman (TeamB - C++ Builder), creator of The Temp{*word*203}Doorway at

http://www.temporaldoorway.com
Quote
> (original digital art, writing, music and more)
> C++ Builder / JBuilder Tips and The C++ Builder Programmer's Webring (Join
us!)
> http://www.temporaldoorway.com/programming/index.htm
> ------

Other Threads