mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 00:58:04 +02:00
Examples: Restructure ComDialogs example.
This commit is contained in:
parent
3c4deba306
commit
7682cf2f88
@ -1,27 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="10"/>
|
||||
<Version Value="12"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
</BuildModes>
|
||||
<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"/>
|
||||
</local>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="1">
|
||||
<Mode0 Name="default"/>
|
||||
</Modes>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
@ -37,7 +35,7 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="EditTest"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<CursorPos X="61" Y="33"/>
|
||||
<CursorPos X="54" Y="17"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
|
@ -4,6 +4,9 @@
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="BitButton_Demo"/>
|
||||
<Scaled Value="True"/>
|
||||
@ -13,8 +16,8 @@
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
@ -23,25 +26,25 @@
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages>
|
||||
<Item>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="bitbutton_demo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="BitButton_Demo"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="bitbtnform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="BitBtnForm"/>
|
||||
</Unit>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
@ -63,16 +66,16 @@
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
@ -4,6 +4,9 @@
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="checkbox_demo"/>
|
||||
<Scaled Value="True"/>
|
||||
@ -14,8 +17,8 @@
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
@ -24,24 +27,24 @@
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages>
|
||||
<Item>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="checkbox_demo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="checkboxform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="CheckBoxForm"/>
|
||||
</Unit>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
@ -63,16 +66,16 @@
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
@ -4,6 +4,9 @@
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="combobox_demo"/>
|
||||
<Scaled Value="True"/>
|
||||
@ -14,8 +17,8 @@
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
@ -24,24 +27,24 @@
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages>
|
||||
<Item>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="combobox_demo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="comboboxform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="ComboBoxForm"/>
|
||||
</Unit>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
@ -63,16 +66,16 @@
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
80
examples/simple/rad/comdialogs/comdialogs_demo.lpi
Normal file
80
examples/simple/rad/comdialogs/comdialogs_demo.lpi
Normal file
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="comdialogs_demo"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="comdialogs_demo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="dlgform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="DlgForm"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="comdialogs_demo"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
26
examples/simple/rad/comdialogs/comdialogs_demo.lpr
Normal file
26
examples/simple/rad/comdialogs/comdialogs_demo.lpr
Normal file
@ -0,0 +1,26 @@
|
||||
program comdialogs_demo;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}
|
||||
cthreads,
|
||||
{$ENDIF}
|
||||
{$IFDEF HASAMIGA}
|
||||
athreads,
|
||||
{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, DlgForm
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource:=True;
|
||||
Application.Title:='project1';
|
||||
Application.Scaled:=True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
85
examples/simple/rad/comdialogs/dlgform.lfm
Normal file
85
examples/simple/rad/comdialogs/dlgform.lfm
Normal file
@ -0,0 +1,85 @@
|
||||
object Form1: TForm1
|
||||
Left = 200
|
||||
Height = 230
|
||||
Top = 200
|
||||
Width = 400
|
||||
Caption = 'Common Dialogs'
|
||||
ClientHeight = 230
|
||||
ClientWidth = 400
|
||||
Color = clTeal
|
||||
LCLVersion = '2.3.0.0'
|
||||
object dirLabel: TLabel
|
||||
Left = 110
|
||||
Height = 15
|
||||
Top = 40
|
||||
Width = 48
|
||||
Caption = 'Directory'
|
||||
end
|
||||
object fileLabel: TLabel
|
||||
Left = 110
|
||||
Height = 15
|
||||
Top = 80
|
||||
Width = 18
|
||||
Caption = 'File'
|
||||
end
|
||||
object closeButton: TButton
|
||||
Tag = 1
|
||||
Left = 110
|
||||
Height = 25
|
||||
Top = 145
|
||||
Width = 75
|
||||
Caption = 'Close'
|
||||
OnClick = ButtonClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object openButton: TButton
|
||||
Tag = 2
|
||||
Left = 10
|
||||
Height = 25
|
||||
Top = 10
|
||||
Width = 75
|
||||
Caption = 'Open'
|
||||
OnClick = ButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object saveButton: TButton
|
||||
Tag = 3
|
||||
Left = 10
|
||||
Height = 25
|
||||
Top = 52
|
||||
Width = 75
|
||||
Caption = 'Save'
|
||||
OnClick = ButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object fontButton: TButton
|
||||
Tag = 4
|
||||
Left = 10
|
||||
Height = 25
|
||||
Top = 94
|
||||
Width = 75
|
||||
Caption = 'Font'
|
||||
OnClick = ButtonClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object colorButton: TButton
|
||||
Tag = 5
|
||||
Left = 10
|
||||
Height = 25
|
||||
Top = 136
|
||||
Width = 75
|
||||
Caption = 'Color'
|
||||
OnClick = ButtonClick
|
||||
TabOrder = 4
|
||||
end
|
||||
object dirButton: TButton
|
||||
Tag = 6
|
||||
Left = 10
|
||||
Height = 25
|
||||
Top = 178
|
||||
Width = 75
|
||||
Caption = 'Directory'
|
||||
OnClick = ButtonClick
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
77
examples/simple/rad/comdialogs/dlgform.pas
Normal file
77
examples/simple/rad/comdialogs/dlgform.pas
Normal file
@ -0,0 +1,77 @@
|
||||
unit DlgForm;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
dirButton: TButton;
|
||||
colorButton: TButton;
|
||||
fontButton: TButton;
|
||||
saveButton: TButton;
|
||||
openButton: TButton;
|
||||
closeButton: TButton;
|
||||
dirLabel: TLabel;
|
||||
fileLabel: TLabel;
|
||||
procedure ButtonClick(Sender: TObject);
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.ButtonClick(Sender: TObject);
|
||||
begin
|
||||
case TButton(Sender).Tag of
|
||||
1 : Close;
|
||||
2 : with TOpenDialog.Create(Self) do
|
||||
begin
|
||||
Filter := '*.pp';
|
||||
Options := Options + [ofAllowMultiSelect];
|
||||
if Execute then fileLabel.Caption := FileName;
|
||||
Free;
|
||||
end;
|
||||
3 : with TSaveDialog.Create(Self) do
|
||||
begin
|
||||
Filename := 'untitled.pp';
|
||||
if Execute then fileLabel.Caption := FileName;
|
||||
Free;
|
||||
end;
|
||||
4 : with TFontDialog.Create(Self) do
|
||||
begin
|
||||
Font.Assign(fontButton.Font);
|
||||
if Execute then fontButton.Font.Assign(Font);
|
||||
Free;
|
||||
end;
|
||||
5 : with TColorDialog.Create(Self) do
|
||||
begin
|
||||
Color := Self.Color;
|
||||
if Execute then Self.Color := Color;
|
||||
Free;
|
||||
end;
|
||||
6 : with TSelectDirectoryDialog.Create(Self) do
|
||||
begin
|
||||
if Execute then dirLabel.Caption := FileName;
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -1,44 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="10"/>
|
||||
<Version Value="12"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
</BuildModes>
|
||||
<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"/>
|
||||
</local>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="1">
|
||||
<Mode0 Name="default"/>
|
||||
</Modes>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="comdialogs.pp"/>
|
||||
<Filename Value="comdialogs_demo.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="ComDialogs"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<CursorPos X="15" Y="25"/>
|
||||
<UnitName Value="ComDialogs_Demo"/>
|
||||
<CursorPos X="35" Y="20"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="dlgform.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="DlgForm"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="52"/>
|
||||
<CursorPos Y="76"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
@ -18,7 +18,7 @@
|
||||
* *
|
||||
***************************************************************************
|
||||
}
|
||||
program ComDialogs;
|
||||
program ComDialogs_Demo;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
@ -65,7 +65,6 @@ begin
|
||||
Parent := Self;
|
||||
SetBounds(110, 40, 280, 35);
|
||||
Caption := 'Directory';
|
||||
Show;
|
||||
end;
|
||||
|
||||
fileLabel := TLabel.Create(Self);
|
||||
@ -74,7 +73,6 @@ begin
|
||||
Parent := Self;
|
||||
SetBounds(110, 80, 280, 35);
|
||||
Caption := 'File';
|
||||
Show;
|
||||
end;
|
||||
|
||||
closeButton := TButton.Create(Self);
|
Loading…
Reference in New Issue
Block a user