Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, StdCtrls, SysUtils, Forms, Controls, Graphics, Dialogs;
- type
- { TForm1 }
- TForm1 = class(TForm)
- ComboBox1: TComboBox;
- Label1: TLabel;
- procedure ComboBox1Change(Sender: TObject);
- procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
- procedure FormCreate(Sender: TObject);
- private
- FStrList: TStringList;
- procedure SetStrList(AValue: TStringList);
- public
- property StrList: TStringList read FStrList write SetStrList;
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.FormCreate(Sender: TObject);
- var
- i: PtrInt = 0;
- begin
- FStrList:= TStringList.Create;
- for i:= 0 to 9 do
- StrList.AddObject(Format('string_%d (added as Object: %d)',[Succ(i),i]),TObject(i));
- ComboBox1.Items.Assign(StrList);
- ComboBox1.ItemIndex:= 0;
- ComboBox1Change(Sender);
- end;
- procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
- begin
- FreeAndNil(FStrList);
- end;
- procedure TForm1.ComboBox1Change(Sender: TObject);
- begin
- Label1.Caption:= 'PtrInt(Object): ' + IntToStr(PtrInt(ComboBox1.Items.Objects[ComboBox1.ItemIndex]));
- end;
- procedure TForm1.SetStrList(AValue: TStringList);
- begin
- if StrList.Equals(AValue) then Exit;
- FStrList.Assign(AValue);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement