summaryrefslogtreecommitdiff
path: root/examples/gui
diff options
context:
space:
mode:
Diffstat (limited to 'examples/gui')
-rw-r--r--examples/gui/colorlistbox/frmMain.pas2
-rw-r--r--examples/gui/combobox/comboboxtest.lpi58
-rw-r--r--examples/gui/combobox/comboboxtest.lpr29
-rw-r--r--examples/gui/combobox/extrafpc.cfg5
-rw-r--r--examples/gui/combobox/frm_main.pas251
-rw-r--r--examples/gui/filedialog/filedialog.lpr8
-rw-r--r--examples/gui/gridtest/gridtest.lpr100
-rw-r--r--examples/gui/listbox/frm_main.pas160
-rw-r--r--examples/gui/listbox/listboxtest.lpi58
-rw-r--r--examples/gui/listbox/listboxtest.lpr29
-rw-r--r--examples/gui/memo/memotest.lpr6
-rw-r--r--examples/gui/menutest/menutest.lpr3
12 files changed, 686 insertions, 23 deletions
diff --git a/examples/gui/colorlistbox/frmMain.pas b/examples/gui/colorlistbox/frmMain.pas
index 7fbe0327..5ec2d98c 100644
--- a/examples/gui/colorlistbox/frmMain.pas
+++ b/examples/gui/colorlistbox/frmMain.pas
@@ -83,7 +83,7 @@ begin
cbName1.Items.Add('cpStandardColors');
cbName1.Items.Add('cpSystemColors');
cbName1.Items.Add('cpWebColors');
- cbName1.FocusItem := 1;
+ cbName1.FocusItem := 0;
cbName1.OnChange := @cbName1Change;
end;
diff --git a/examples/gui/combobox/comboboxtest.lpi b/examples/gui/combobox/comboboxtest.lpi
new file mode 100644
index 00000000..41183e45
--- /dev/null
+++ b/examples/gui/combobox/comboboxtest.lpi
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="/"/>
+ <Version Value="6"/>
+ <General>
+ <Flags>
+ <SaveOnlyProjectUnits Value="True"/>
+ </Flags>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=""/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="1">
+ <Item1>
+ <PackageName Value="fpgui_package"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="2">
+ <Unit0>
+ <Filename Value="comboboxtest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="comboboxtest"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="frm_main.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="frm_main"/>
+ </Unit1>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CustomOptions Value="-FUunits"/>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/examples/gui/combobox/comboboxtest.lpr b/examples/gui/combobox/comboboxtest.lpr
new file mode 100644
index 00000000..a3a38da1
--- /dev/null
+++ b/examples/gui/combobox/comboboxtest.lpr
@@ -0,0 +1,29 @@
+program comboboxtest;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Classes, fpgfx, frm_main;
+
+procedure MainProc;
+var
+ frm: TMainForm;
+begin
+ fpgApplication.Initialize;
+ frm := TMainForm.Create(nil);
+ try
+ frm.Show;
+ fpgApplication.Run;
+ finally
+ frm.Free;
+ end;
+end;
+
+begin
+ MainProc;
+end.
+
+
diff --git a/examples/gui/combobox/extrafpc.cfg b/examples/gui/combobox/extrafpc.cfg
new file mode 100644
index 00000000..073dc4b6
--- /dev/null
+++ b/examples/gui/combobox/extrafpc.cfg
@@ -0,0 +1,5 @@
+-FUunits
+-Fu../../../lib
+-Xs
+-XX
+-CX
diff --git a/examples/gui/combobox/frm_main.pas b/examples/gui/combobox/frm_main.pas
new file mode 100644
index 00000000..2b834b51
--- /dev/null
+++ b/examples/gui/combobox/frm_main.pas
@@ -0,0 +1,251 @@
+unit frm_main;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ SysUtils, Classes, gfxbase, fpgfx, gui_edit,
+ gfx_widget, gui_form, gui_label, gui_button,
+ gui_listbox, gui_memo, gui_combobox, gui_basegrid, gui_grid,
+ gui_dialogs, gui_checkbox, gui_tree, gui_trackbar,
+ gui_progressbar, gui_radiobutton, gui_tab, gui_menu,
+ gui_panel, gui_popupcalendar, gui_gauge, gui_editcombo;
+
+type
+
+ TMainForm = class(TfpgForm)
+ private
+ procedure cbAutoCompleteChanged(Sender: TObject);
+ procedure cbAutoDropDownChanged(Sender: TObject);
+ procedure cbAllowNewChanged(Sender: TObject);
+ procedure btnAdd1Clicked(Sender: TObject);
+ procedure btnFocusClicked(Sender: TObject);
+ procedure btnClearClicked(Sender: TObject);
+ procedure btnAdd10Clicked(Sender: TObject);
+ public
+ {@VFD_HEAD_BEGIN: MainForm}
+ btnAdd10: TfpgButton;
+ btnClear: TfpgButton;
+ btnFocus: TfpgButton;
+ btnAdd1: TfpgButton;
+ cbAutoComplete: TfpgCheckBox;
+ Combo1: TfpgComboBox;
+ lblName1: TfpgLabel;
+ lblName2: TfpgLabel;
+ EditCombo1: TfpgEditCombo;
+ cbAutoDropdown: TfpgCheckBox;
+ lblName3: TfpgLabel;
+ lblName4: TfpgLabel;
+ cbAllowNew: TfpgComboBox;
+ {@VFD_HEAD_END: MainForm}
+ procedure AfterCreate; override;
+ end;
+
+{@VFD_NEWFORM_DECL}
+
+implementation
+
+{@VFD_NEWFORM_IMPL}
+
+procedure TMainForm.cbAutoCompleteChanged(Sender: TObject);
+begin
+ EditCombo1.AutoCompletion := cbAutoComplete.Checked;
+end;
+
+procedure TMainForm.cbAutoDropDownChanged(Sender: TObject);
+begin
+ EditCombo1.AutoDropDown := cbAutoDropdown.Checked;
+end;
+
+procedure TMainForm.cbAllowNewChanged(Sender: TObject);
+begin
+ if cbAllowNew.Text = 'anNo' then
+ EditCombo1.AllowNew := anNo
+ else if cbAllowNew.Text = 'anYes' then
+ EditCombo1.AllowNew := anYes
+ else if cbAllowNew.Text = 'anAsk' then
+ EditCombo1.AllowNew := anAsk
+end;
+
+procedure TMainForm.btnAdd1Clicked(Sender: TObject);
+begin
+ Combo1.Items.Add(Format('Item %2d', [Combo1.Items.Count]));
+ EditCombo1.Items.Add(Format('Item %2d', [EditCombo1.Items.Count]));
+end;
+
+procedure TMainForm.btnFocusClicked(Sender: TObject);
+begin
+ if Combo1.Items.Count > 1 then
+ Combo1.FocusItem := 2;
+ if EditCombo1.Items.Count > 1 then
+ EditCombo1.FocusItem := 2;
+end;
+
+procedure TMainForm.btnClearClicked(Sender: TObject);
+begin
+ Combo1.Items.Clear;
+ EditCombo1.Items.Clear;
+end;
+
+procedure TMainForm.btnAdd10Clicked(Sender: TObject);
+var
+ i: integer;
+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]));
+ end;
+end;
+
+procedure TMainForm.AfterCreate;
+begin
+ {@VFD_BODY_BEGIN: MainForm}
+ Name := 'MainForm';
+ SetPosition(345, 220, 344, 260);
+ WindowTitle := 'ComboBox test';
+ WindowPosition := wpScreenCenter;
+
+ btnAdd10 := TfpgButton.Create(self);
+ with btnAdd10 do
+ begin
+ Name := 'btnAdd10';
+ SetPosition(220, 28, 92, 23);
+ Text := 'Add 10 items';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 1;
+ OnClick := @btnAdd10Clicked;
+ end;
+
+ btnClear := TfpgButton.Create(self);
+ with btnClear do
+ begin
+ Name := 'btnClear';
+ SetPosition(220, 56, 92, 23);
+ Text := 'Clear Items';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 2;
+ OnClick := @btnClearClicked;
+ end;
+
+ btnFocus := TfpgButton.Create(self);
+ with btnFocus do
+ begin
+ Name := 'btnFocus';
+ SetPosition(220, 84, 92, 23);
+ Text := 'FocusItem = 2';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 3;
+ OnClick := @btnFocusClicked;
+ end;
+
+ btnAdd1 := TfpgButton.Create(self);
+ with btnAdd1 do
+ begin
+ Name := 'btnAdd1';
+ SetPosition(220, 112, 92, 23);
+ Text := 'Add 1 item';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 4;
+ OnClick := @btnAdd1Clicked;
+ end;
+
+ cbAutoComplete := TfpgCheckBox.Create(self);
+ with cbAutoComplete do
+ begin
+ Name := 'cbAutoComplete';
+ SetPosition(216, 168, 120, 19);
+ FontDesc := '#Label1';
+ TabOrder := 6;
+ Text := 'Auto Complete';
+ OnChange := @cbAutoCompleteChanged;
+ end;
+
+ Combo1 := TfpgComboBox.Create(self);
+ with Combo1 do
+ begin
+ Name := 'Combo1';
+ SetPosition(8, 24, 168, 21);
+ FontDesc := '#List';
+ TabOrder := 6;
+ end;
+
+ lblName1 := TfpgLabel.Create(self);
+ with lblName1 do
+ begin
+ Name := 'lblName1';
+ SetPosition(8, 8, 176, 15);
+ FontDesc := '#Label1';
+ Text := 'Static ComboBox';
+ end;
+
+ lblName2 := TfpgLabel.Create(self);
+ with lblName2 do
+ begin
+ Name := 'lblName2';
+ SetPosition(8, 68, 176, 15);
+ FontDesc := '#Label1';
+ Text := 'Edit ComboBox';
+ end;
+
+ EditCombo1 := TfpgEditCombo.Create(self);
+ with EditCombo1 do
+ begin
+ Name := 'EditCombo1';
+ SetPosition(8, 88, 168, 21);
+ end;
+
+ cbAutoDropdown := TfpgCheckBox.Create(self);
+ with cbAutoDropdown do
+ begin
+ Name := 'cbAutoDropdown';
+ SetPosition(216, 188, 120, 19);
+ FontDesc := '#Label1';
+ TabOrder := 9;
+ Text := 'Auto Dropdown';
+ OnChange := @cbAutoDropDownChanged;
+ end;
+
+ lblName3 := TfpgLabel.Create(self);
+ with lblName3 do
+ begin
+ Name := 'lblName3';
+ SetPosition(204, 148, 128, 15);
+ FontDesc := '#Label2';
+ Text := 'EditCombo only';
+ end;
+
+ lblName4 := TfpgLabel.Create(self);
+ with lblName4 do
+ begin
+ Name := 'lblName4';
+ SetPosition(204, 8, 136, 15);
+ FontDesc := '#Label2';
+ Text := 'Both components';
+ end;
+
+ cbAllowNew := TfpgComboBox.Create(self);
+ with cbAllowNew do
+ begin
+ Name := 'cbAllowNew';
+ SetPosition(220, 212, 100, 21);
+ FontDesc := '#List';
+ Items.Add('anNo');
+ Items.Add('anYes');
+ Items.Add('anAsk');
+ TabOrder := 13;
+ OnChange := @cbAllowNewChanged;
+ FocusItem := 0;
+ end;
+
+ {@VFD_BODY_END: MainForm}
+
+end;
+
+
+end.
diff --git a/examples/gui/filedialog/filedialog.lpr b/examples/gui/filedialog/filedialog.lpr
index 29635dbb..e7fa99ce 100644
--- a/examples/gui/filedialog/filedialog.lpr
+++ b/examples/gui/filedialog/filedialog.lpr
@@ -55,7 +55,7 @@ type
function TMyDBLoginDlg.GetDatabase: TfpgString;
begin
- Result := aStringList.ValueFromIndex[cbDatabases.FocusItem-1];
+ Result := aStringList.ValueFromIndex[cbDatabases.FocusItem];
end;
procedure TMyDBLoginDlg.PopulateComboDb;
@@ -64,9 +64,9 @@ var
begin
aStringList.Clear;
aStringList.Add('Database1=192.168.0.1:/data/db1.gdb');
- aStringList.Add('Database2=192.168.0.10:/data/live.gdb');
- aStringList.Add('Database3=192.168.0.150:/data/sometest.gdb');
- aStringList.Add('Database4=192.168.0.200:c:\MyData\test.gdb');
+ aStringList.Add('Database2=192.168.0.10:/data/db2.gdb');
+ aStringList.Add('Database3=192.168.0.150:/data/db3.gdb');
+ aStringList.Add('Database4=192.168.0.200:c:\MyData\db4.gdb');
cbDatabases.Items.Clear;
for i := 0 to aStringList.Count-1 do
cbDatabases.Items.Add(aStringList.Names[i]);
diff --git a/examples/gui/gridtest/gridtest.lpr b/examples/gui/gridtest/gridtest.lpr
index a7bbe7fc..2bd6d4ec 100644
--- a/examples/gui/gridtest/gridtest.lpr
+++ b/examples/gui/gridtest/gridtest.lpr
@@ -34,13 +34,21 @@ type
chkDisabled: TfpgCheckBox;
edtTopRow: TfpgEditInteger;
btnTopRow: TfpgButton;
+ btnAddFive: TfpgButton;
+ btnAddOne: TfpgButton;
+ btnFiveOnly: TfpgButton;
{@VFD_HEAD_END: MainForm}
+ procedure StringGridDoubleClicked(Sender: TObject; AButton: TMouseButton;
+ AShift: TShiftState; const AMousePos: TPoint);
+ procedure btnAddFiveClicked(Sender: TObject);
+ procedure btnAddOneClicked(Sender: TObject);
+ procedure btnFiveOnlyClicked(Sender: TObject);
procedure chkDisabledChange(Sender: TObject);
procedure chkRowSelectChange(Sender: TObject);
procedure chkShowHeaderChange(Sender: TObject);
procedure chkShowGridChange(Sender: TObject);
procedure btnQuitClick(Sender: TObject);
- procedure stringgridDrawCell(Sender: TObject; const ARow, ACol: Longword;
+ procedure stringgridDrawCell(Sender: TObject; const ARow, ACol: Integer;
const ARect: TfpgRect; const AFlags: TfpgGridDrawState; var ADefaultDrawing: boolean);
procedure btnTopRowClicked(Sender: TObject);
public
@@ -51,6 +59,30 @@ type
{ TMainForm }
+procedure TMainForm.StringGridDoubleClicked(Sender: TObject;
+ AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
+var
+ lCol, lRow: integer;
+begin
+ StringGrid.MouseToCell(AMousePos.X, AMousePos.Y, lCol, lRow);
+ StringGrid.Cells[lCol, lRow] := Format('(c%d,r%d)', [lCol, lRow]);
+end;
+
+procedure TMainForm.btnAddFiveClicked(Sender: TObject);
+begin
+ StringGrid.RowCount := StringGrid.RowCount + 5;
+end;
+
+procedure TMainForm.btnAddOneClicked(Sender: TObject);
+begin
+ StringGrid.RowCount := StringGrid.RowCount + 1;
+end;
+
+procedure TMainForm.btnFiveOnlyClicked(Sender: TObject);
+begin
+ StringGrid.RowCount := 5;
+end;
+
procedure TMainForm.chkDisabledChange(Sender: TObject);
begin
stringgrid.Enabled := not chkDisabled.Checked;
@@ -77,7 +109,7 @@ begin
end;
procedure TMainForm.stringgridDrawCell(Sender: TObject; const ARow,
- ACol: Longword; const ARect: TfpgRect; const AFlags: TfpgGridDrawState;
+ ACol: Integer; const ARect: TfpgRect; const AFlags: TfpgGridDrawState;
var ADefaultDrawing: boolean);
begin
if (ACol = 1) and (ARow = 3) then
@@ -93,7 +125,7 @@ end;
procedure TMainForm.btnTopRowClicked(Sender: TObject);
begin
- if edtTopRow.Value < 1 then
+ if edtTopRow.Value < 0 then
Exit;
stringgrid.TopRow := edtTopRow.Value;
end;
@@ -104,7 +136,7 @@ var
begin
{@VFD_BODY_BEGIN: MainForm}
Name := 'MainForm';
- SetPosition(351, 214, 566, 350);
+ SetPosition(351, 214, 515, 350);
WindowTitle := 'Grid control test';
WindowPosition := wpScreenCenter;
@@ -112,7 +144,7 @@ begin
with btnQuit do
begin
Name := 'btnQuit';
- SetPosition(476, 320, 80, 25);
+ SetPosition(425, 320, 80, 25);
Anchors := [anRight,anBottom];
Text := 'Quit';
FontDesc := '#Label1';
@@ -124,11 +156,12 @@ begin
with stringgrid do
begin
Name := 'stringgrid';
- SetPosition(10, 10, 426, 250);
+ SetPosition(10, 10, 375, 250);
Anchors := [anLeft,anRight,anTop,anBottom];
+ AddColumn('Column 0', 65);
AddColumn('Column 1', 100, taLeftJustify);
AddColumn('Col 2', 50, taCenter);
- AddColumn('New', 150, taRightJustify);
+ AddColumn('Numbers', 150, taRightJustify);
FontDesc := '#Grid';
HeaderFontDesc := '#GridHeader';
RowCount := 17;
@@ -143,12 +176,14 @@ begin
TextColor:= clBlue;
ColumnTextColor[1] := clRed;
// add some text
- Cells[1, 1] := '(r1,c1)';
+ Cells[0, 0] := '[c0, r0]';
+ Cells[1, 1] := '[c1, r1]';
Cells[1, 3] := 'Custom';
Cells[2, 3] := 'Hello';
- Cells[3, 1] := '(r1,c3)';
+ Cells[3, 1] := '[c3, r1]';
// Add custom painting
- OnDrawCell := @stringgridDrawCell;
+ OnDrawCell := @StringGridDrawCell;
+ OnDoubleClick := @StringGridDoubleClicked;
end;
chkShowHeader := TfpgCheckBox.Create(self);
@@ -168,7 +203,7 @@ begin
with chkShowGrid do
begin
Name := 'chkShowGrid';
- SetPosition(110, 320, 100, 24);
+ SetPosition(114, 320, 92, 24);
Anchors := [anLeft,anBottom];
Checked := True;
FontDesc := '#Label1';
@@ -213,7 +248,7 @@ begin
with btnTopRow do
begin
Name := 'btnTopRow';
- SetPosition(76, 280, 91, 24);
+ SetPosition(72, 280, 91, 23);
Anchors := [anLeft,anBottom];
Text := 'Set TopRow';
FontDesc := '#Label1';
@@ -222,9 +257,48 @@ begin
OnClick := @btnTopRowClicked;
end;
+ btnAddFive := TfpgButton.Create(self);
+ with btnAddFive do
+ begin
+ Name := 'btnAddFive';
+ SetPosition(188, 280, 80, 23);
+ Anchors := [anLeft,anBottom];
+ Text := 'Add 5 lines';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 8;
+ OnClick := @btnAddFiveClicked;
+ end;
+
+ btnAddOne := TfpgButton.Create(self);
+ with btnAddOne do
+ begin
+ Name := 'btnAddOne';
+ SetPosition(272, 280, 80, 23);
+ Anchors := [anLeft,anBottom];
+ Text := 'Add 1 line';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 9;
+ OnClick := @btnAddOneClicked;
+ end;
+
+ btnFiveOnly := TfpgButton.Create(self);
+ with btnFiveOnly do
+ begin
+ Name := 'btnFiveOnly';
+ SetPosition(356, 280, 80, 23);
+ Anchors := [anLeft,anBottom];
+ Text := '5 lines only';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 10;
+ OnClick := @btnFiveOnlyClicked;
+ end;
+
{@VFD_BODY_END: MainForm}
- for r := 1 to stringgrid.RowCount do
+ for r := 0 to stringgrid.RowCount-1 do
stringgrid.Cells[3, r] := IntToStr(r);
end;
diff --git a/examples/gui/listbox/frm_main.pas b/examples/gui/listbox/frm_main.pas
new file mode 100644
index 00000000..9757bfc9
--- /dev/null
+++ b/examples/gui/listbox/frm_main.pas
@@ -0,0 +1,160 @@
+unit frm_main;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ SysUtils, Classes, gfxbase, fpgfx, gui_edit,
+ gfx_widget, gui_form, gui_label, gui_button,
+ gui_listbox, gui_memo, gui_combobox, gui_basegrid, gui_grid,
+ gui_dialogs, gui_checkbox, gui_tree, gui_trackbar,
+ gui_progressbar, gui_radiobutton, gui_tab, gui_menu,
+ gui_panel, gui_popupcalendar, gui_gauge;
+
+type
+
+ TMainForm = class(TfpgForm)
+ private
+ procedure cbHotTrackChanged(Sender: TObject);
+ procedure btnAdd1Clicked(Sender: TObject);
+ procedure btnFocusClicked(Sender: TObject);
+ procedure btnClearClicked(Sender: TObject);
+ procedure btnAdd10Clicked(Sender: TObject);
+ public
+ {@VFD_HEAD_BEGIN: MainForm}
+ lstName1: TfpgListBox;
+ btnAdd10: TfpgButton;
+ btnClear: TfpgButton;
+ btnFocus: TfpgButton;
+ btnAdd1: TfpgButton;
+ memName1: TfpgMemo;
+ cbHotTrack: TfpgCheckBox;
+ {@VFD_HEAD_END: MainForm}
+ procedure AfterCreate; override;
+ end;
+
+{@VFD_NEWFORM_DECL}
+
+implementation
+
+{@VFD_NEWFORM_IMPL}
+
+procedure TMainForm.cbHotTrackChanged(Sender: TObject);
+begin
+ lstName1.HotTrack := cbHotTrack.Checked;
+end;
+
+procedure TMainForm.btnAdd1Clicked(Sender: TObject);
+begin
+ lstName1.Items.Add(Format('Item %2d', [lstName1.ItemCount]));
+end;
+
+procedure TMainForm.btnFocusClicked(Sender: TObject);
+begin
+ if lstName1.ItemCount > 1 then
+ lstName1.FocusItem := 2;
+end;
+
+procedure TMainForm.btnClearClicked(Sender: TObject);
+begin
+ lstName1.Items.Clear;
+end;
+
+procedure TMainForm.btnAdd10Clicked(Sender: TObject);
+var
+ i: integer;
+begin
+ for i := 1 to 10 do
+ lstName1.Items.Add(Format('Item %2d', [lstName1.ItemCount]));
+end;
+
+procedure TMainForm.AfterCreate;
+begin
+ {@VFD_BODY_BEGIN: MainForm}
+ Name := 'MainForm';
+ SetPosition(345, 220, 300, 270);
+ WindowTitle := 'ListBox test';
+ WindowPosition := wpScreenCenter;
+
+ lstName1 := TfpgListBox.Create(self);
+ with lstName1 do
+ begin
+ Name := 'lstName1';
+ SetPosition(12, 12, 128, 168);
+ FontDesc := '#List';
+ end;
+
+ btnAdd10 := TfpgButton.Create(self);
+ with btnAdd10 do
+ begin
+ Name := 'btnAdd10';
+ SetPosition(204, 28, 92, 23);
+ Text := 'Add 10 items';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 1;
+ OnClick := @btnAdd10Clicked;
+ end;
+
+ btnClear := TfpgButton.Create(self);
+ with btnClear do
+ begin
+ Name := 'btnClear';
+ SetPosition(204, 56, 92, 23);
+ Text := 'Clear Items';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 2;
+ OnClick := @btnClearClicked;
+ end;
+
+ btnFocus := TfpgButton.Create(self);
+ with btnFocus do
+ begin
+ Name := 'btnFocus';
+ SetPosition(204, 84, 92, 23);
+ Text := 'FocusItem = 2';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 3;
+ OnClick := @btnFocusClicked;
+ end;
+
+ btnAdd1 := TfpgButton.Create(self);
+ with btnAdd1 do
+ begin
+ Name := 'btnAdd1';
+ SetPosition(204, 112, 92, 23);
+ Text := 'Add 1 item';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 4;
+ OnClick := @btnAdd1Clicked;
+ end;
+
+ memName1 := TfpgMemo.Create(self);
+ with memName1 do
+ begin
+ Name := 'memName1';
+ SetPosition(12, 188, 280, 77);
+ FontDesc := '#Edit1';
+ TabOrder := 5;
+ end;
+
+ cbHotTrack := TfpgCheckBox.Create(self);
+ with cbHotTrack do
+ begin
+ Name := 'cbHotTrack';
+ SetPosition(204, 140, 120, 19);
+ FontDesc := '#Label1';
+ TabOrder := 6;
+ Text := 'Track Focus';
+ OnChange := @cbHotTrackChanged;
+ end;
+
+ {@VFD_BODY_END: MainForm}
+end;
+
+
+end.
diff --git a/examples/gui/listbox/listboxtest.lpi b/examples/gui/listbox/listboxtest.lpi
new file mode 100644
index 00000000..f80a70b0
--- /dev/null
+++ b/examples/gui/listbox/listboxtest.lpi
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="/"/>
+ <Version Value="6"/>
+ <General>
+ <Flags>
+ <SaveOnlyProjectUnits Value="True"/>
+ </Flags>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=""/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="1">
+ <Item1>
+ <PackageName Value="fpgui_package"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="2">
+ <Unit0>
+ <Filename Value="listboxtest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="listboxtest"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="frm_main.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="frm_main"/>
+ </Unit1>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CustomOptions Value="-FUunits"/>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/examples/gui/listbox/listboxtest.lpr b/examples/gui/listbox/listboxtest.lpr
new file mode 100644
index 00000000..dd14a408
--- /dev/null
+++ b/examples/gui/listbox/listboxtest.lpr
@@ -0,0 +1,29 @@
+program listboxtest;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Classes, fpgfx, frm_main, fpgui_package;
+
+procedure MainProc;
+var
+ frm: TMainForm;
+begin
+ fpgApplication.Initialize;
+ frm := TMainForm.Create(nil);
+ try
+ frm.Show;
+ fpgApplication.Run;
+ finally
+ frm.Free;
+ end;
+end;
+
+begin
+ MainProc;
+end.
+
+
diff --git a/examples/gui/memo/memotest.lpr b/examples/gui/memo/memotest.lpr
index c3e106a8..e4eed10b 100644
--- a/examples/gui/memo/memotest.lpr
+++ b/examples/gui/memo/memotest.lpr
@@ -57,9 +57,9 @@ begin
memo.Lines.Add('Memo Test0');
memo.Lines.Add('Memo Test1');
- //memo.Lines.Add('Memo Test2');
- //memo.Lines.Add('Memo Test3');
- //memo.Lines.Add('Memo Test4');
+ memo.Lines.Add('Memo Test2');
+ memo.Lines.Add('Memo Test3');
+ memo.Lines.Add('Memo Test4');
memo.Lines.Insert(1,'0 Before 1 after');
//memo.Lines.Delete(1);
//memo.Lines.Text := 'Dude'+LineEnding+'What''s mine say?'+LineEnding;;
diff --git a/examples/gui/menutest/menutest.lpr b/examples/gui/menutest/menutest.lpr
index c95c49de..801bdb97 100644
--- a/examples/gui/menutest/menutest.lpr
+++ b/examples/gui/menutest/menutest.lpr
@@ -77,8 +77,7 @@ begin
FHelpSubMenu.AddMenuItem('Test Russian text -> Òåñò', '', @miMenuItemSelected);
// Create main menu bar
- FMenuBar := TfpgMenuBar.Create(self);
- FMenuBar.SetPosition(0, 0, Width, FMenuBar.Height);
+ FMenuBar := CreateMenuBar(self);
FMenuBar.AddMenuItem('&File', nil).SubMenu := FFileSubMenu;
FMenuBar.AddMenuItem('&Edit', nil).SubMenu := FEditSubMenu;
FMenuBar.AddMenuItem('&Windows', nil);