[DUG] control has no parent window error Delphi 2007
Jolyon Smith
jsmith at deltics.co.nz
Tue Sep 6 17:49:07 NZST 2011
Combobox controls can be tricky as some pretty basic initialisations of
those controls require that messages be sent to the control which requires
that the underlying HWND has been allocated and that in turn requires that
the control's parent *also* has a HWND.
Most often this can trip you up when you initialise these controls in the
constructor or OnCreate events of a form - the temptation is to think that
if the form has been "created" then there must be a window, right ? But
this isn't always the case.
If the code that is causing you trouble is in a form constructor or OnCreate
event, try moving it to the OnShow event instead - this will occur only
after the form actually has an underlying window. If that solves the
problem then window timing is the problem and you should take a closer look
at the initialisation required by the control and the best place to perform
it.
It may even be that you can simply leave the initialisation to occur in the
OnShow event.
hth
On 6 September 2011 16:39, Vik Vasudev <vikas.image at gmail.com> wrote:
> Hello Everyone,
>
> I am getting this "Control has no parent window error" when i try to load a
> form in insert mode. i mean to say it has datasource assigned to it.
>
>
> I have a Tabsheet with a panel control.
>
> So code snippet like.
> here Tdemo is derived from TCustomDropDownCheckBox
>
> X = Tdemo.create (self)
> X.parent := Panel.
> .X.datasource = yz;
>
> Problem is when the dataset is loaded in insert mode at first instance it
> gives this error. Then when i move to other component and comes back it
> works fine.
>
> I suspect parent handle is not getting assigned.
>
> Any help or idea on this be appreciated
> --
> vikas
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20110906/398d4262/attachment.html
More information about the Delphi
mailing list