From 4d3dbec5a9fdaa97792c107073083e7489ea605e Mon Sep 17 00:00:00 2001 From: graemeg Date: Tue, 3 Jun 2008 10:50:49 +0000 Subject: * Added a RandomData unit to the examples/gui directory. * Updated the ComboBox demo to use the RandomData unit. --- examples/gui/combobox/comboboxtest.lpi | 10 +++++++++- examples/gui/combobox/comboboxtest.lpr | 2 +- examples/gui/combobox/extrafpc.cfg | 2 +- examples/gui/combobox/frm_main.pas | 33 ++++++++++++++++++++++++++++----- 4 files changed, 39 insertions(+), 8 deletions(-) (limited to 'examples/gui/combobox') diff --git a/examples/gui/combobox/comboboxtest.lpi b/examples/gui/combobox/comboboxtest.lpi index 41183e45..c950242d 100644 --- a/examples/gui/combobox/comboboxtest.lpi +++ b/examples/gui/combobox/comboboxtest.lpi @@ -32,7 +32,7 @@ - + @@ -43,10 +43,18 @@ + + + + + + + + diff --git a/examples/gui/combobox/comboboxtest.lpr b/examples/gui/combobox/comboboxtest.lpr index a3a38da1..313a9c0f 100644 --- a/examples/gui/combobox/comboboxtest.lpr +++ b/examples/gui/combobox/comboboxtest.lpr @@ -6,7 +6,7 @@ uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} - Classes, fpgfx, frm_main; + Classes, fpgfx, frm_main, RandomData; procedure MainProc; var diff --git a/examples/gui/combobox/extrafpc.cfg b/examples/gui/combobox/extrafpc.cfg index 073dc4b6..a68a9d08 100644 --- a/examples/gui/combobox/extrafpc.cfg +++ b/examples/gui/combobox/extrafpc.cfg @@ -1,5 +1,5 @@ -FUunits --Fu../../../lib +-Fu../../../lib;../common -Xs -XX -CX diff --git a/examples/gui/combobox/frm_main.pas b/examples/gui/combobox/frm_main.pas index 2b834b51..b0be0713 100644 --- a/examples/gui/combobox/frm_main.pas +++ b/examples/gui/combobox/frm_main.pas @@ -39,13 +39,17 @@ type lblName4: TfpgLabel; cbAllowNew: TfpgComboBox; {@VFD_HEAD_END: MainForm} - procedure AfterCreate; override; + constructor Create(AOwner: TComponent); override; + procedure AfterCreate; override; end; {@VFD_NEWFORM_DECL} implementation +uses + RandomData; + {@VFD_NEWFORM_IMPL} procedure TMainForm.cbAutoCompleteChanged(Sender: TObject); @@ -69,9 +73,16 @@ begin end; procedure TMainForm.btnAdd1Clicked(Sender: TObject); +var + Gender: TGender; + n: string; begin - Combo1.Items.Add(Format('Item %2d', [Combo1.Items.Count])); - EditCombo1.Items.Add(Format('Item %2d', [EditCombo1.Items.Count])); + Gender := TGender(Random(2)); + n := RandomFullName(Gender); + Combo1.Items.Add(n); + EditCombo1.Items.Add(n); + Combo1.Items.Sort; + EditCombo1.Items.Sort; end; procedure TMainForm.btnFocusClicked(Sender: TObject); @@ -91,12 +102,24 @@ end; procedure TMainForm.btnAdd10Clicked(Sender: TObject); var i: integer; + Gender: TGender; + n: string; begin for i := 1 to 10 do begin - Combo1.Items.Add(Format('Item %2d', [Combo1.Items.Count])); - EditCombo1.Items.Add(Format('Item %2d', [EditCombo1.Items.Count])); + Gender := TGender(Random(2)); + n := RandomFullName(Gender); + Combo1.Items.Add(n); + EditCombo1.Items.Add(n); end; + Combo1.Items.Sort; + EditCombo1.Items.Sort; +end; + +constructor TMainForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Randomize; end; procedure TMainForm.AfterCreate; -- cgit v1.2.3-70-g09d2