mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 23:59:24 +02:00
Examples: Replace lfm-less ListViewTest demo by version with lfm form.
This commit is contained in:
parent
d275b33da0
commit
d0b21a465b
@ -1,48 +1,61 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="10"/>
|
<Version Value="12"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
<SaveOnlyProjectUnits Value="True"/>
|
<CompatibilityMode Value="True"/>
|
||||||
<LRSInOutputDirectory Value="False"/>
|
|
||||||
</Flags>
|
</Flags>
|
||||||
<MainUnit Value="0"/>
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<Title Value="listviewtest"/>
|
||||||
|
<Scaled Value="True"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
<UseXPManifest Value="True"/>
|
||||||
|
<XPManifest>
|
||||||
|
<DpiAware Value="True"/>
|
||||||
|
</XPManifest>
|
||||||
|
<Icon Value="0"/>
|
||||||
</General>
|
</General>
|
||||||
<BuildModes Count="1">
|
<BuildModes Count="1">
|
||||||
<Item1 Name="default" Default="True"/>
|
<Item1 Name="Default" Default="True"/>
|
||||||
</BuildModes>
|
</BuildModes>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IgnoreBinaries Value="False"/>
|
<UseFileFilters Value="True"/>
|
||||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
|
||||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<FormatVersion Value="2"/>
|
||||||
<FormatVersion Value="1"/>
|
|
||||||
</local>
|
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="1">
|
<RequiredPackages Count="1">
|
||||||
<Item1>
|
<Item1>
|
||||||
<PackageName Value="LCL"/>
|
<PackageName Value="LCL"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="1">
|
<Units Count="2">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="listviewtest.pp"/>
|
<Filename Value="listviewtest.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="ListViewTest"/>
|
|
||||||
<IsVisibleTab Value="True"/>
|
|
||||||
<CursorPos X="51" Y="24"/>
|
|
||||||
<UsageCount Value="20"/>
|
|
||||||
<Loaded Value="True"/>
|
|
||||||
<LoadedDesigner Value="True"/>
|
|
||||||
</Unit0>
|
</Unit0>
|
||||||
|
<Unit1>
|
||||||
|
<Filename Value="listviewtestfrm.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<ComponentName Value="MyForm"/>
|
||||||
|
<ResourceBaseClass Value="Form"/>
|
||||||
|
<UnitName Value="ListViewTestFrm"/>
|
||||||
|
</Unit1>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="11"/>
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="listviewtest"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
<Linking>
|
<Linking>
|
||||||
<Options>
|
<Options>
|
||||||
<Win32>
|
<Win32>
|
||||||
@ -51,4 +64,17 @@
|
|||||||
</Options>
|
</Options>
|
||||||
</Linking>
|
</Linking>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="3">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item3>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
</CONFIG>
|
</CONFIG>
|
||||||
|
26
examples/listviewtest.lpr
Normal file
26
examples/listviewtest.lpr
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
program listviewtest;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$IFDEF UNIX}
|
||||||
|
cthreads,
|
||||||
|
{$ENDIF}
|
||||||
|
{$IFDEF HASAMIGA}
|
||||||
|
athreads,
|
||||||
|
{$ENDIF}
|
||||||
|
Interfaces, // this includes the LCL widgetset
|
||||||
|
Forms, ListViewTestFrm
|
||||||
|
{ you can add units after this };
|
||||||
|
|
||||||
|
{$R *.res}
|
||||||
|
|
||||||
|
begin
|
||||||
|
RequireDerivedFormResource:=True;
|
||||||
|
Application.Title:='project1';
|
||||||
|
Application.Scaled:=True;
|
||||||
|
Application.Initialize;
|
||||||
|
Application.CreateForm(TMyForm, MyForm);
|
||||||
|
Application.Run;
|
||||||
|
end.
|
||||||
|
|
@ -1,166 +0,0 @@
|
|||||||
{
|
|
||||||
/***************************************************************************
|
|
||||||
ListViewTest.pp
|
|
||||||
-------------------
|
|
||||||
Test aplication for list views
|
|
||||||
Initial Revision : Sun Dec 31 17:30:00:00 CET 2000
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
***************************************************************************
|
|
||||||
* *
|
|
||||||
* This source is free software; you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* This code is distributed in the hope that it will be useful, but *
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
||||||
* General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* A copy of the GNU General Public License is available on the World *
|
|
||||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
|
||||||
* obtain it by writing to the Free Software Foundation, *
|
|
||||||
* Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
|
|
||||||
* *
|
|
||||||
***************************************************************************
|
|
||||||
}
|
|
||||||
|
|
||||||
program ListViewTest;
|
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
|
||||||
|
|
||||||
uses
|
|
||||||
Interfaces, Classes, Buttons, Controls, ComCtrls, Forms, SysUtils,
|
|
||||||
Graphics, StdCtrls;
|
|
||||||
|
|
||||||
type
|
|
||||||
TMyForm = class(TForm)
|
|
||||||
private
|
|
||||||
FItemIndex: Cardinal;
|
|
||||||
public
|
|
||||||
ListView: TListView;
|
|
||||||
Button1: TButton;
|
|
||||||
Button2: TButton;
|
|
||||||
Edit1: TEdit;
|
|
||||||
Edit2: TEdit;
|
|
||||||
constructor Create(AOwner: TComponent); override;
|
|
||||||
procedure Button1Click(Sender: TObject);
|
|
||||||
procedure Button2Click(Sender: TObject);
|
|
||||||
procedure Edit1Change(Sender: TObject);
|
|
||||||
procedure Edit2Change(Sender: TObject);
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
|
||||||
MyForm: TMyForm;
|
|
||||||
|
|
||||||
constructor TMyForm.Create(AOwner: TComponent);
|
|
||||||
begin
|
|
||||||
inherited CreateNew(AOwner, 1);
|
|
||||||
|
|
||||||
Caption := 'List View Test';
|
|
||||||
Width := 300;
|
|
||||||
Height := 200;
|
|
||||||
|
|
||||||
ListView := TListView.Create(Self);
|
|
||||||
ListView.Parent := Self;
|
|
||||||
ListView.Height := 150;
|
|
||||||
ListView.Align := alTop;
|
|
||||||
ListView.ViewStyle := vsReport;
|
|
||||||
ListView.Show;
|
|
||||||
|
|
||||||
ListView.Columns.Add.Caption := 'Column 1';
|
|
||||||
ListView.Columns.Add.Caption := 'Column 2';
|
|
||||||
ListView.Columns.Add.Caption := 'Column 3';
|
|
||||||
|
|
||||||
Button1 := TButton.Create(Self);
|
|
||||||
with Button1 do
|
|
||||||
begin
|
|
||||||
Parent := Self;
|
|
||||||
Caption := 'Add Item';
|
|
||||||
Top := 160;
|
|
||||||
Left := 10;
|
|
||||||
Height := 25;
|
|
||||||
Width := 65;
|
|
||||||
OnClick := @Button1Click;
|
|
||||||
Show;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Button2 := TButton.Create(Self);
|
|
||||||
with Button2 do
|
|
||||||
begin
|
|
||||||
Parent := Self;
|
|
||||||
Caption := 'Del Item';
|
|
||||||
Top := 160;
|
|
||||||
Left := 80;
|
|
||||||
Height := 25;
|
|
||||||
Width := 65;
|
|
||||||
OnClick := @Button2Click;
|
|
||||||
Show;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Edit1 := TEdit.Create(Self);
|
|
||||||
with Edit1 do
|
|
||||||
begin
|
|
||||||
Parent := Self;
|
|
||||||
Top := 160;
|
|
||||||
Left := 150;
|
|
||||||
Height := 25;
|
|
||||||
Width := 65;
|
|
||||||
OnChange := @Edit1Change;
|
|
||||||
Show;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Edit2 := TEdit.Create(Self);
|
|
||||||
with Edit2 do
|
|
||||||
begin
|
|
||||||
Parent := Self;
|
|
||||||
Top := 160;
|
|
||||||
Left := 220;
|
|
||||||
Height := 25;
|
|
||||||
Width := 65;
|
|
||||||
OnChange := @Edit2Change;
|
|
||||||
Show;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Show;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMyForm.Button1Click(Sender: TObject);
|
|
||||||
var
|
|
||||||
Item: TListItem;
|
|
||||||
begin
|
|
||||||
Inc(FItemIndex);
|
|
||||||
Item := ListView.Items.Add;
|
|
||||||
Item.Caption := Format('Item %d', [FItemIndex]);
|
|
||||||
Item.SubItems.Add(Format('Sub %d.1', [FItemIndex]));
|
|
||||||
Item.SubItems.Add(Format('Sub %d.2', [FItemIndex]));
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMyForm.Button2Click(Sender: TObject);
|
|
||||||
begin
|
|
||||||
ListView.Selected.Free;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMyForm.Edit1Change(Sender: TObject);
|
|
||||||
begin
|
|
||||||
if ListView.Selected = nil then Exit;
|
|
||||||
ListView.Selected.Caption := Edit1.Text;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMyForm.Edit2Change(Sender: TObject);
|
|
||||||
begin
|
|
||||||
if ListView.Selected = nil then Exit;
|
|
||||||
ListView.Selected.SubItems[0] := Edit2.Text;
|
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
|
||||||
Application.Initialize;
|
|
||||||
Application.CreateForm(TMyForm, MyForm);
|
|
||||||
Application.Run;
|
|
||||||
end.
|
|
||||||
|
|
64
examples/listviewtestfrm.lfm
Normal file
64
examples/listviewtestfrm.lfm
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
object MyForm: TMyForm
|
||||||
|
Left = 270
|
||||||
|
Height = 200
|
||||||
|
Top = 131
|
||||||
|
Width = 300
|
||||||
|
Caption = 'ListView Test'
|
||||||
|
ClientHeight = 200
|
||||||
|
ClientWidth = 300
|
||||||
|
LCLVersion = '2.3.0.0'
|
||||||
|
object ListView: TListView
|
||||||
|
Left = 0
|
||||||
|
Height = 150
|
||||||
|
Top = 0
|
||||||
|
Width = 300
|
||||||
|
Align = alTop
|
||||||
|
Columns = <
|
||||||
|
item
|
||||||
|
Caption = 'Column 1'
|
||||||
|
end
|
||||||
|
item
|
||||||
|
Caption = 'Column 2'
|
||||||
|
end
|
||||||
|
item
|
||||||
|
Caption = 'Column 3'
|
||||||
|
end>
|
||||||
|
HideSelection = False
|
||||||
|
TabOrder = 0
|
||||||
|
ViewStyle = vsReport
|
||||||
|
end
|
||||||
|
object Button1: TButton
|
||||||
|
Left = 10
|
||||||
|
Height = 25
|
||||||
|
Top = 160
|
||||||
|
Width = 65
|
||||||
|
Caption = 'Add Item'
|
||||||
|
OnClick = Button1Click
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object Button2: TButton
|
||||||
|
Left = 80
|
||||||
|
Height = 25
|
||||||
|
Top = 160
|
||||||
|
Width = 65
|
||||||
|
Caption = 'Del Item'
|
||||||
|
OnClick = Button2Click
|
||||||
|
TabOrder = 2
|
||||||
|
end
|
||||||
|
object Edit1: TEdit
|
||||||
|
Left = 150
|
||||||
|
Height = 23
|
||||||
|
Top = 160
|
||||||
|
Width = 65
|
||||||
|
OnChange = Edit1Change
|
||||||
|
TabOrder = 3
|
||||||
|
end
|
||||||
|
object Edit2: TEdit
|
||||||
|
Left = 220
|
||||||
|
Height = 23
|
||||||
|
Top = 160
|
||||||
|
Width = 65
|
||||||
|
OnChange = Edit2Change
|
||||||
|
TabOrder = 4
|
||||||
|
end
|
||||||
|
end
|
68
examples/listviewtestfrm.pas
Normal file
68
examples/listviewtestfrm.pas
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
unit ListViewTestFrm;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TMyForm }
|
||||||
|
|
||||||
|
TMyForm = class(TForm)
|
||||||
|
Button1: TButton;
|
||||||
|
Button2: TButton;
|
||||||
|
Edit1: TEdit;
|
||||||
|
Edit2: TEdit;
|
||||||
|
ListView: TListView;
|
||||||
|
procedure Button1Click(Sender: TObject);
|
||||||
|
procedure Button2Click(Sender: TObject);
|
||||||
|
procedure Edit1Change(Sender: TObject);
|
||||||
|
procedure Edit2Change(Sender: TObject);
|
||||||
|
private
|
||||||
|
FItemIndex: Cardinal;
|
||||||
|
public
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
MyForm: TMyForm;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
|
{ TMyForm }
|
||||||
|
|
||||||
|
procedure TMyForm.Button1Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
Item: TListItem;
|
||||||
|
begin
|
||||||
|
Inc(FItemIndex);
|
||||||
|
Item := ListView.Items.Add;
|
||||||
|
Item.Caption := Format('Item %d', [FItemIndex]);
|
||||||
|
Item.SubItems.Add(Format('Sub %d.1', [FItemIndex]));
|
||||||
|
Item.SubItems.Add(Format('Sub %d.2', [FItemIndex]));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMyForm.Button2Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ListView.Selected.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMyForm.Edit1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if ListView.Selected = nil then Exit;
|
||||||
|
ListView.Selected.Caption := Edit1.Text;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMyForm.Edit2Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if ListView.Selected = nil then Exit;
|
||||||
|
ListView.Selected.SubItems[0] := Edit2.Text;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user