[DUG] control has no parent window error Delphi 2007

Vik Vasudev vikas.image at gmail.com
Tue Sep 6 21:09:54 NZST 2011


Thanks for your reply Jolyon,

Unfortunately on show event fail to do its magic. Having said that i  gave a
try by assigning parentwindow of that control to
parent handle, Since i assumed when parent window gets 0 value it triggers
that exception. But i was wrong.

I need to work on some other way to get this working. I will post soon once
i find a way to it.

Thanks

On Tue, Sep 6, 2011 at 5:49 PM, Jolyon Smith <jsmith at deltics.co.nz> wrote:

> 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
>>
>
>
> _______________________________________________
> 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
>



-- 
  vikas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20110906/13f02e9a/attachment.html 


More information about the Delphi mailing list