GridPrinter: Add example with StringGrid.Columns.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8638 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-12-06 22:40:27 +00:00
parent da1a1d25fc
commit fb21c53cbd
4 changed files with 272 additions and 0 deletions

View File

@ -0,0 +1,90 @@
<?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="project1"/>
<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="3">
<Item1>
<PackageName Value="Printer4Lazarus"/>
</Item1>
<Item2>
<PackageName Value="GridPrinterPkg"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf3"/>
</Debugging>
<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>

View File

@ -0,0 +1,25 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
{$IFDEF HASAMIGA}
athreads,
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, printer4lazarus, Unit1
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,114 @@
object Form1: TForm1
Left = 256
Height = 324
Top = 134
Width = 303
Caption = 'Form1'
ClientHeight = 324
ClientWidth = 303
LCLVersion = '2.3.0.0'
object StringGrid1: TStringGrid
Left = 0
Height = 287
Top = 0
Width = 303
Align = alClient
ColCount = 4
Columns = <
item
Title.Caption = 'Col 1'
Width = 64
end
item
Alignment = taRightJustify
Title.Alignment = taRightJustify
Title.Caption = 'Col 2'
Width = 64
end
item
ButtonStyle = cbsCheckboxColumn
Color = clActiveBorder
Title.Alignment = taCenter
Title.Caption = 'Col 3'
Width = 64
end>
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll, goFixedRowNumbering]
TabOrder = 0
Cells = (
11
1
1
'abc'
1
2
'def'
1
3
'ghi'
1
4
'jkl'
2
1
'test 1'
2
2
'test 2'
2
3
'test 3'
2
4
'test 5'
3
1
'1'
3
2
'0'
3
4
'1'
)
end
object Panel1: TPanel
Left = 0
Height = 37
Top = 287
Width = 303
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 37
ClientWidth = 303
TabOrder = 1
object Button1: TButton
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 6
Height = 25
Top = 6
Width = 75
BorderSpacing.Around = 6
Caption = 'Preview...'
OnClick = Button1Click
TabOrder = 0
end
end
object GridPrinter1: TGridPrinter
Grid = StringGrid1
Footer.Font.Height = -11
Footer.FontSize = 8
Header.Font.Height = -11
Header.FontSize = 8
ShowPrintDialog = gpdPrintDialog
Left = 63
Top = 143
end
object GridPrintPreviewDialog1: TGridPrintPreviewDialog
FormParams.PixelsPerInch = 96
GridPrinter = GridPrinter1
Left = 192
Top = 143
end
end

View File

@ -0,0 +1,43 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids, ExtCtrls,
StdCtrls, GridPrn, GridPrnPreviewDlg;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
GridPrinter1: TGridPrinter;
GridPrintPreviewDialog1: TGridPrintPreviewDialog;
Panel1: TPanel;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
GridPrintPreviewDialog1.Execute;
end;
end.