Lazarus

Programming => LCL => Topic started by: morphocr on May 14, 2011, 02:02:11 am

Title: Error on AddObject TabControl.Tabs
Post by: morphocr on May 14, 2011, 02:02:11 am
it works on the combobox.items but not in tabcontrol.tabs and both use tstrings

Code: [Select]

  tmyclass = class
    tt  : integer;
    a   : string;
  end;
.
.
.

procedure TForm1.Button1Click(Sender: TObject);
var
   i      : integer;
   temp   : tmyclass;
begin
     for i := 1 to 10 do
     begin
          temp := tmyclass.Create;
          temp.a:='object#'+inttostr(i);
          temp.tt:=i;
          ComboBox1.Items.AddObject(temp.a,temp);
          TabControl1.Tabs.AddObject(temp.a,temp);
     end;
     for i := 0 to ComboBox1.Items.Count-1 do
     begin
          showmessage(inttostr(tmyclass(ComboBox1.Items.Objects[i]).tt));
          showmessage(inttostr(tmyclass(TabControl1.tabs.Objects[i]).tt));
     end;
end;
Title: Re: Error on AddObject TabControl.Tabs
Post by: DirkS on May 14, 2011, 10:03:46 am
What error do you get?
It would also be useful if you give details about Lazarus / Freepascal version, etc.

Gr.
Dirk.
Title: Re: Error on AddObject TabControl.Tabs
Post by: morphocr on May 14, 2011, 11:46:47 pm
What error do you get?
It would also be useful if you give details about Lazarus / Freepascal version, etc.

Gr.
Dirk.


thanks for your reply,

when trying to get any objects from
Code: [Select]
TabControl1.tabs.Objects[i] it come with -(maxInteger) value instead of the object pointer, and im using the
follow Ide :

- Lazarus Version #: 0.9.30
- Date: 2011-05-13
- FPC Version: 2.4.2
- SVN Revision: 29811M

  for i386-linux-gtk 2 on Fedora 14 Box
Title: Re: Error on AddObject TabControl.Tabs
Post by: morphocr on May 20, 2011, 10:34:20 pm
anyone follow this ?
Title: Re: Error on AddObject TabControl.Tabs
Post by: eny on May 20, 2011, 11:56:45 pm
I'm assuming this is because ComboBox1.Items and TabControl1.Tabs are different beasts.
ComboBox.Items is an actual TStringList (which has the Objects property implemented as expected).
TabControl.Tabs is a TTabControlNoteBookStrings that has some fancy methods (not in the least an overriden PutObject(...)).

Just create a separate TStringList where you store the info you need for your tabs.
TinyPortal © 2005-2018