BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

add data to Tstrings

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Nathan
Guest





PostPosted: Mon Nov 24, 2003 11:31 pm    Post subject: add data to Tstrings Reply with quote



Hi everybody

I create a TComboBox with some data in the items when I add it to form I
got a ErrMsg "Control has no parent window" I debug it I see it stop when
it add the data to the items property

Here is the my code



TdsDateComboBox = class(TCustomComboBox);

....



constructor TdsDateComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Style:= csDropDownList;
Items.Add('All');
Items.Add('Today');
Items.Add('This Week');
Items.Add('This Week-to-date');



Please reply thanks

Nathan


Back to top
Yorai Aminov (TeamB)
Guest





PostPosted: Tue Nov 25, 2003 12:22 am    Post subject: Re: add data to Tstrings Reply with quote



On Mon, 24 Nov 2003 18:31:45 -0500, "Nathan" <nerenthal (AT) hotmail (DOT) com>
wrote:

Quote:
I create a TComboBox with some data in the items when I add it to form I
got a ErrMsg "Control has no parent window"

You're trying to access the combo box items in the constructor.
Unfortunately, the items list is implemented as a wrapper around the
standard combo box messages. This means they are only accessible once
a window handle is created.

You can override the CreateWnd method and add your items then. Note
that the method is called whenever the window is recreated, so you'll
probably want to set a flag somewhere to avoid inserting the items
more than once.

---
Yorai Aminov (TeamB)
http://develop.shorterpath.com/yorai
(TeamB cannot answer questions received via email.)

Back to top
JED
Guest





PostPosted: Tue Nov 25, 2003 12:29 am    Post subject: Re: add data to Tstrings Reply with quote



Nathan wrote:

Quote:
Hi everybody

I create a TComboBox with some data in the items when I add it to
form I got a ErrMsg "Control has no parent window" I debug it I see
it stop when it add the data to the items property


You could override the Loaded method and add the items there.

HTH,

jed


Back to top
Peter Below (TeamB)
Guest





PostPosted: Tue Nov 25, 2003 6:46 pm    Post subject: Re: add data to Tstrings Reply with quote

In article <3fc294ba$1 (AT) newsgroups (DOT) borland.com>, Nathan wrote:
Quote:
I create a TComboBox with some data in the items when I add it to form I
got a ErrMsg "Control has no parent window" I debug it I see it stop when
it add the data to the items property

Here is the my code

TdsDateComboBox = class(TCustomComboBox);

constructor TdsDateComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Style:= csDropDownList;
Items.Add('All');
Items.Add('Today');
Items.Add('This Week');
Items.Add('This Week-to-date');

As indicated by the other replies you cannot do things in the constructor
that require the controls window handle to exist. But using Items.Add should
work without the handle, the control will buffer the data into a temp
TStringlist instance. What does require the window handle, however, is an
attempt to set the ItemIndex. You should move that to an overriden CreateWnd
or SetParent method.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.