mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 07:59:45 +02:00
improved win32 printers from Boguslaw Brandys
git-svn-id: trunk@8304 -
This commit is contained in:
parent
ecff79f1e2
commit
eaac6a33da
@ -26,7 +26,7 @@
|
|||||||
<License Value="LGPL
|
<License Value="LGPL
|
||||||
"/>
|
"/>
|
||||||
<Version Build="2"/>
|
<Version Build="2"/>
|
||||||
<Files Count="24">
|
<Files Count="26">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="printersdlgs.lrs"/>
|
<Filename Value="printersdlgs.lrs"/>
|
||||||
<Type Value="LRS"/>
|
<Type Value="LRS"/>
|
||||||
@ -128,6 +128,14 @@
|
|||||||
<Filename Value="win32\winprinters_h.inc"/>
|
<Filename Value="win32\winprinters_h.inc"/>
|
||||||
<Type Value="Include"/>
|
<Type Value="Include"/>
|
||||||
</Item24>
|
</Item24>
|
||||||
|
<Item25>
|
||||||
|
<Filename Value="win32\winprndialogs.inc"/>
|
||||||
|
<Type Value="Include"/>
|
||||||
|
</Item25>
|
||||||
|
<Item26>
|
||||||
|
<Filename Value="linux\cupsprndialogs.inc"/>
|
||||||
|
<Type Value="Include"/>
|
||||||
|
</Item26>
|
||||||
</Files>
|
</Files>
|
||||||
<Type Value="RunAndDesignTime"/>
|
<Type Value="RunAndDesignTime"/>
|
||||||
<RequiredPkgs Count="2">
|
<RequiredPkgs Count="2">
|
||||||
|
@ -4,9 +4,19 @@ Printer4Lazarus package
|
|||||||
This package add some components.
|
This package add some components.
|
||||||
TPrinterSetupDialog : for update properties of selected printer
|
TPrinterSetupDialog : for update properties of selected printer
|
||||||
TPrintDialog : for select and/or update an printer before printing
|
TPrintDialog : for select and/or update an printer before printing
|
||||||
|
TPageSetupDialog : to select margins (currently only under Windows)
|
||||||
|
|
||||||
Win32 :
|
Win32 :
|
||||||
Native implementation
|
Native implementation
|
||||||
|
Notes:
|
||||||
|
1. TPrinter.CanRenderCopies return information if printer driver is able to print more then one copy at once.
|
||||||
|
Not all printers drivers support that feature (n that case programmer should print document requested times)
|
||||||
|
|
||||||
|
2.TPrintDialog.Options indicate which controls should be visible in dialog.
|
||||||
|
TPrintDialog.PrintToFile indicate that output will be redirected to file.
|
||||||
|
|
||||||
|
3.Some (mostly advanced) settings of printer driver are not preserved between two calls to TPrintDialog.Execute function.
|
||||||
|
|
||||||
|
|
||||||
Linux :
|
Linux :
|
||||||
Yous must install CUPS and libcups v1.1.19 or more.
|
Yous must install CUPS and libcups v1.1.19 or more.
|
||||||
@ -14,3 +24,4 @@ Linux :
|
|||||||
FAQ :
|
FAQ :
|
||||||
Q:If I use Printers unit, the call of printer object générate an exception "Access Violation"
|
Q:If I use Printers unit, the call of printer object générate an exception "Access Violation"
|
||||||
R:Add in uses clause of your project, osPrinters
|
R:Add in uses clause of your project, osPrinters
|
||||||
|
|
||||||
|
@ -4,22 +4,22 @@ object Form1: TForm1
|
|||||||
ClientHeight = 487
|
ClientHeight = 487
|
||||||
ClientWidth = 339
|
ClientWidth = 339
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
PixelsPerInch = 75
|
PixelsPerInch = 96
|
||||||
Position = poDesktopCenter
|
Position = poDesktopCenter
|
||||||
HorzScrollBar.Page = 338
|
HorzScrollBar.Page = 338
|
||||||
VertScrollBar.Page = 486
|
VertScrollBar.Page = 486
|
||||||
Left = 212
|
Left = 230
|
||||||
Height = 487
|
Height = 487
|
||||||
Top = 47
|
Top = 36
|
||||||
Width = 339
|
Width = 339
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
Caption = 'This sample show how to use the printer dialogs'
|
Caption = 'This sample show how to use the printer dialogs'
|
||||||
Color = clNone
|
Color = clNone
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
Left = 16
|
Left = 16
|
||||||
Height = 13
|
Height = 14
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 269
|
Width = 226
|
||||||
end
|
end
|
||||||
object Button2: TButton
|
object Button2: TButton
|
||||||
BorderSpacing.InnerBorder = 2
|
BorderSpacing.InnerBorder = 2
|
||||||
@ -51,17 +51,17 @@ object Form1: TForm1
|
|||||||
MaxSize = 350
|
MaxSize = 350
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
Title.Caption = 'Information'
|
Title.Caption = 'Information'
|
||||||
Width = 250
|
Width = 230
|
||||||
end>
|
end>
|
||||||
DefaultColWidth = 70
|
DefaultColWidth = 90
|
||||||
FixedColor = clBtnFace
|
FixedColor = clBtnFace
|
||||||
Flat = True
|
Flat = True
|
||||||
GridLineWidth = 0
|
GridLineWidth = 0
|
||||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goSmoothScroll]
|
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goSmoothScroll]
|
||||||
RowCount = 12
|
RowCount = 15
|
||||||
ScrollBars = ssAutoBoth
|
ScrollBars = ssAutoBoth
|
||||||
VisibleColCount = 1
|
VisibleColCount = 1
|
||||||
VisibleRowCount = 11
|
VisibleRowCount = 14
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 288
|
Height = 288
|
||||||
Top = 192
|
Top = 192
|
||||||
@ -118,10 +118,20 @@ object Form1: TForm1
|
|||||||
Width = 320
|
Width = 320
|
||||||
end
|
end
|
||||||
object PSD: TPrinterSetupDialog
|
object PSD: TPrinterSetupDialog
|
||||||
|
Title = 'Testing dialog title'
|
||||||
left = 176
|
left = 176
|
||||||
top = 240
|
top = 240
|
||||||
end
|
end
|
||||||
object PD: TPrintDialog
|
object PD: TPrintDialog
|
||||||
|
Collate = True
|
||||||
|
Copies = 1
|
||||||
|
FromPage = 2
|
||||||
|
MinPage = 2
|
||||||
|
MaxPage = 5
|
||||||
|
Options = [poPrintToFile, poPageNums, poSelection, poWarning, poHelp]
|
||||||
|
PrintToFile = True
|
||||||
|
ToPage = 3
|
||||||
|
Title = 'Testing title'
|
||||||
left = 176
|
left = 176
|
||||||
top = 272
|
top = 272
|
||||||
end
|
end
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
{ This is an automatically generated lazarus resource file }
|
{ To jest automatycznie wygenerowany plik zasobów lazarusa }
|
||||||
|
|
||||||
LazarusResources.Add('TForm1','FORMDATA',[
|
LazarusResources.Add('TForm1','FORMDATA',[
|
||||||
'TPF0'#6'TForm1'#5'Form1'#13'ActiveControl'#7#7'Button2'#7'Caption'#6#5'Form1'
|
'TPF0'#6'TForm1'#5'Form1'#13'ActiveControl'#7#7'Button2'#7'Caption'#6#5'Form1'
|
||||||
+#12'ClientHeight'#3#231#1#11'ClientWidth'#3'S'#1#8'OnCreate'#7#10'FormCreate'
|
+#12'ClientHeight'#3#231#1#11'ClientWidth'#3'S'#1#8'OnCreate'#7#10'FormCreate'
|
||||||
+#13'PixelsPerInch'#2'K'#8'Position'#7#15'poDesktopCenter'#18'HorzScrollBar.P'
|
+#13'PixelsPerInch'#2'`'#8'Position'#7#15'poDesktopCenter'#18'HorzScrollBar.P'
|
||||||
+'age'#3'R'#1#18'VertScrollBar.Page'#3#230#1#4'Left'#3#212#0#6'Height'#3#231#1
|
+'age'#3'R'#1#18'VertScrollBar.Page'#3#230#1#4'Left'#3#230#0#6'Height'#3#231#1
|
||||||
+#3'Top'#2'/'#5'Width'#3'S'#1#0#6'TLabel'#6'Label1'#7'Caption'#6'/This sample'
|
+#3'Top'#2'$'#5'Width'#3'S'#1#0#6'TLabel'#6'Label1'#7'Caption'#6'/This sample'
|
||||||
+' show how to use the printer dialogs'#5'Color'#7#6'clNone'#11'ParentColor'#8
|
+' show how to use the printer dialogs'#5'Color'#7#6'clNone'#11'ParentColor'#8
|
||||||
+#4'Left'#2#16#6'Height'#2#13#3'Top'#2#8#5'Width'#3#13#1#0#0#7'TButton'#7'But'
|
+#4'Left'#2#16#6'Height'#2#14#3'Top'#2#8#5'Width'#3#226#0#0#0#7'TButton'#7'Bu'
|
||||||
+'ton2'#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#27'Execute TPrinterSet'
|
+'tton2'#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#27'Execute TPrinterSe'
|
||||||
+'upDialog'#7'OnClick'#7#12'Button2Click'#8'TabOrder'#2#0#4'Left'#2#8#6'Heigh'
|
+'tupDialog'#7'OnClick'#7#12'Button2Click'#8'TabOrder'#2#0#4'Left'#2#8#6'Heig'
|
||||||
+'t'#2#27#3'Top'#2'3'#5'Width'#3'@'#1#0#0#7'TButton'#7'Button1'#25'BorderSpac'
|
+'ht'#2#27#3'Top'#2'3'#5'Width'#3'@'#1#0#0#7'TButton'#7'Button1'#25'BorderSpa'
|
||||||
+'ing.InnerBorder'#2#2#7'Caption'#6#20'Execute TPrintDialog'#7'OnClick'#7#12
|
+'cing.InnerBorder'#2#2#7'Caption'#6#20'Execute TPrintDialog'#7'OnClick'#7#12
|
||||||
+'Button1Click'#8'TabOrder'#2#1#4'Left'#2#8#6'Height'#2#27#3'Top'#2'N'#5'Widt'
|
+'Button1Click'#8'TabOrder'#2#1#4'Left'#2#8#6'Height'#2#27#3'Top'#2'N'#5'Widt'
|
||||||
+'h'#3'@'#1#0#0#11'TStringGrid'#5'SGrid'#15'AutoFillColumns'#9#11'BorderStyle'
|
+'h'#3'@'#1#0#0#11'TStringGrid'#5'SGrid'#15'AutoFillColumns'#9#11'BorderStyle'
|
||||||
+#7#6'bsNone'#8'ColCount'#2#2#7'Columns'#14#1#7'MinSize'#2'<'#7'MaxSize'#3'^'
|
+#7#6'bsNone'#8'ColCount'#2#2#7'Columns'#14#1#7'MinSize'#2'<'#7'MaxSize'#3'^'
|
||||||
+#1#8'ReadOnly'#9#13'Title.Caption'#6#11'Information'#5'Width'#3#250#0#0#0#15
|
+#1#8'ReadOnly'#9#13'Title.Caption'#6#11'Information'#5'Width'#3#230#0#0#0#15
|
||||||
+'DefaultColWidth'#2'F'#10'FixedColor'#7#9'clBtnFace'#4'Flat'#9#13'GridLineWi'
|
+'DefaultColWidth'#2'Z'#10'FixedColor'#7#9'clBtnFace'#4'Flat'#9#13'GridLineWi'
|
||||||
+'dth'#2#0#7'Options'#11#15'goFixedVertLine'#15'goFixedHorzLine'#10'goVertLin'
|
+'dth'#2#0#7'Options'#11#15'goFixedVertLine'#15'goFixedHorzLine'#10'goVertLin'
|
||||||
+'e'#10'goHorzLine'#13'goRangeSelect'#14'goSmoothScroll'#0#8'RowCount'#2#12#10
|
+'e'#10'goHorzLine'#13'goRangeSelect'#14'goSmoothScroll'#0#8'RowCount'#2#15#10
|
||||||
+'ScrollBars'#7#10'ssAutoBoth'#15'VisibleColCount'#2#1#15'VisibleRowCount'#2
|
+'ScrollBars'#7#10'ssAutoBoth'#15'VisibleColCount'#2#1#15'VisibleRowCount'#2
|
||||||
+#11#4'Left'#2#8#6'Height'#3' '#1#3'Top'#3#192#0#5'Width'#3'@'#1#0#0#7'TButto'
|
+#14#4'Left'#2#8#6'Height'#3' '#1#3'Top'#3#192#0#5'Width'#3'@'#1#0#0#7'TButto'
|
||||||
+'n'#7'Button3'#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#24'Get default'
|
+'n'#7'Button3'#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#24'Get default'
|
||||||
+' printer info'#7'OnClick'#7#12'Button3Click'#8'TabOrder'#2#2#4'Left'#2#8#6
|
+' printer info'#7'OnClick'#7#12'Button3Click'#8'TabOrder'#2#2#4'Left'#2#8#6
|
||||||
+'Height'#2#27#3'Top'#2'i'#5'Width'#3'@'#1#0#0#7'TButton'#7'Button4'#25'Borde'
|
+'Height'#2#27#3'Top'#2'i'#5'Width'#3'@'#1#0#0#7'TButton'#7'Button4'#25'Borde'
|
||||||
@ -34,9 +34,12 @@ LazarusResources.Add('TForm1','FORMDATA',[
|
|||||||
+'Height'#2#25#3'Top'#3#157#0#5'Width'#3#224#0#0#0#7'TButton'#7'Button7'#25'B'
|
+'Height'#2#25#3'Top'#3#157#0#5'Width'#3#224#0#0#0#7'TButton'#7'Button7'#25'B'
|
||||||
+'orderSpacing.InnerBorder'#2#2#7'Caption'#6#24'Execute TPageSetupDialog'#7'O'
|
+'orderSpacing.InnerBorder'#2#2#7'Caption'#6#24'Execute TPageSetupDialog'#7'O'
|
||||||
+'nClick'#7#12'Button7Click'#8'TabOrder'#2#6#4'Left'#2#8#6'Height'#2#27#3'Top'
|
+'nClick'#7#12'Button7Click'#8'TabOrder'#2#6#4'Left'#2#8#6'Height'#2#27#3'Top'
|
||||||
+#2#24#5'Width'#3'@'#1#0#0#19'TPrinterSetupDialog'#3'PSD'#4'left'#3#176#0#3't'
|
+#2#24#5'Width'#3'@'#1#0#0#19'TPrinterSetupDialog'#3'PSD'#5'Title'#6#20'Testi'
|
||||||
+'op'#3#240#0#0#0#12'TPrintDialog'#2'PD'#4'left'#3#176#0#3'top'#3#16#1#0#0#10
|
+'ng dialog title'#4'left'#3#176#0#3'top'#3#240#0#0#0#12'TPrintDialog'#2'PD'#7
|
||||||
+'TPopupMenu'#10'PopupMenu1'#4'left'#3#216#0#3'top'#3#240#0#0#0#16'TPageSetup'
|
+'Collate'#9#6'Copies'#2#1#8'FromPage'#2#2#7'MinPage'#2#2#7'MaxPage'#2#5#7'Op'
|
||||||
+'Dialog'#5'PAGED'#5'Title'#6#25'Ustawienie strony raportu'#4'left'#3#176#0#3
|
+'tions'#11#13'poPrintToFile'#10'poPageNums'#11'poSelection'#9'poWarning'#6'p'
|
||||||
+'top'#3'0'#1#0#0#0
|
+'oHelp'#0#11'PrintToFile'#9#6'ToPage'#2#3#5'Title'#6#13'Testing title'#4'lef'
|
||||||
|
+'t'#3#176#0#3'top'#3#16#1#0#0#10'TPopupMenu'#10'PopupMenu1'#4'left'#3#216#0#3
|
||||||
|
+'top'#3#240#0#0#0#16'TPageSetupDialog'#5'PAGED'#5'Title'#6#25'Ustawienie str'
|
||||||
|
+'ony raportu'#4'left'#3#176#0#3'top'#3'0'#1#0#0#0
|
||||||
]);
|
]);
|
||||||
|
@ -54,8 +54,11 @@ type
|
|||||||
procedure Button7Click(Sender: TObject);
|
procedure Button7Click(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
private
|
private
|
||||||
|
ck : Integer;
|
||||||
procedure UpdatePrinterInfo;
|
procedure UpdatePrinterInfo;
|
||||||
|
procedure AddInfo(const Desc : String; Const Info : String);
|
||||||
public
|
public
|
||||||
|
|
||||||
{ public declarations }
|
{ public declarations }
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -68,18 +71,14 @@ uses
|
|||||||
|
|
||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
|
procedure TForm1.AddInfo(const Desc : String; Const Info : String);
|
||||||
|
begin
|
||||||
|
SGrid.Cells[0,ck] := Desc;
|
||||||
|
SGrid.Cells[1,ck] := Info;
|
||||||
|
Inc(ck);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.UpdatePrinterInfo;
|
procedure TForm1.UpdatePrinterInfo;
|
||||||
var
|
|
||||||
ck : Integer;
|
|
||||||
s : String;
|
|
||||||
|
|
||||||
procedure AddInfo(const Desc : String; Const Info : String);
|
|
||||||
begin
|
|
||||||
SGrid.Cells[0,ck] := Desc;
|
|
||||||
SGrid.Cells[1,ck] := Info;
|
|
||||||
Inc(ck);
|
|
||||||
end;
|
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
ck := 1;
|
ck := 1;
|
||||||
@ -109,23 +108,10 @@ begin
|
|||||||
psStopped:AddInfo('PrinterState','Stopped');
|
psStopped:AddInfo('PrinterState','Stopped');
|
||||||
end;
|
end;
|
||||||
AddInfo('PaperSize',PaperSize.PaperName);
|
AddInfo('PaperSize',PaperSize.PaperName);
|
||||||
with PAGED do begin
|
if CanRenderCopies then AddInfo('CanRenderCopies','true')
|
||||||
if PAGED.Units = unMM then
|
else
|
||||||
begin
|
AddInfo('CanRenderCopies','false');
|
||||||
s :=' milimeters';
|
|
||||||
s := Format('[%d,%d,%d,%d] %s',[Margins.Top div 100,
|
|
||||||
Margins.Left div 100, Margins.Bottom div 100, Margins.Right div 100,
|
|
||||||
s]);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
s :=' inches';
|
|
||||||
s := Format('[%d,%d,%d,%d] %s',[Margins.Top div 1000,
|
|
||||||
Margins.Left div 1000,Margins.Bottom div 1000,Margins.Right div 1000,
|
|
||||||
s]);
|
|
||||||
end;
|
|
||||||
AddInfo('Margins',s);
|
|
||||||
end;
|
|
||||||
if not CanPrint then
|
if not CanPrint then
|
||||||
Application.MessageBox('Selected printer cannot print currently!',
|
Application.MessageBox('Selected printer cannot print currently!',
|
||||||
'Warning',mb_iconexclamation);
|
'Warning',mb_iconexclamation);
|
||||||
@ -135,7 +121,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TForm1.Button2Click(Sender: TObject);
|
procedure TForm1.Button2Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if PSD.Execute then
|
if PSD.Execute then
|
||||||
@ -157,15 +142,15 @@ begin
|
|||||||
Printer.Canvas.Font.Size := 12;
|
Printer.Canvas.Font.Size := 12;
|
||||||
Printer.Canvas.TextOut(0,0,'This is test for lazarus printer4lazarus package');
|
Printer.Canvas.TextOut(0,0,'This is test for lazarus printer4lazarus package');
|
||||||
Printer.EndDoc;
|
Printer.EndDoc;
|
||||||
except on E:Exception do
|
except
|
||||||
begin
|
on E:Exception do
|
||||||
Printer.Abort;
|
begin
|
||||||
Application.MessageBox(pChar(e.message),'Error',mb_iconhand);
|
Printer.Abort;
|
||||||
|
Application.MessageBox(pChar(e.message),'Error',mb_iconhand);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TForm1.Button5Click(Sender: TObject);
|
procedure TForm1.Button5Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
UpdatePrinterInfo;
|
UpdatePrinterInfo;
|
||||||
@ -174,15 +159,37 @@ end;
|
|||||||
procedure TForm1.Button6Click(Sender: TObject);
|
procedure TForm1.Button6Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
{$IFDEF WIN32}
|
{$IFDEF WIN32}
|
||||||
TWinPrinter(Printer).Properties;
|
TWinPrinter(Printer).AdvancedProperties;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
ShowMessage('Printer.Properties is not implemented for this platform');
|
ShowMessage('Printer.AdvancedProperties is not yet implemented for this platform');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.Button7Click(Sender: TObject);
|
procedure TForm1.Button7Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
s : String;
|
||||||
begin
|
begin
|
||||||
if PAGED.Execute then UpdatePrinterInfo;
|
if PAGED.Execute then
|
||||||
|
begin
|
||||||
|
UpdatePrinterInfo;
|
||||||
|
with PAGED do begin
|
||||||
|
if PAGED.Units = unMM then
|
||||||
|
begin
|
||||||
|
s :=' milimeters';
|
||||||
|
s := Format('[%d,%d,%d,%d] %s',[Margins.Top div 100,
|
||||||
|
Margins.Left div 100, Margins.Bottom div 100, Margins.Right div 100,
|
||||||
|
s]);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
s :=' inches';
|
||||||
|
s := Format('[%d,%d,%d,%d] %s',[Margins.Top div 1000,
|
||||||
|
Margins.Left div 1000,Margins.Bottom div 1000,Margins.Right div 1000,
|
||||||
|
s]);
|
||||||
|
end;
|
||||||
|
AddInfo('Margins',s);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormCreate(Sender: TObject);
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
@ -194,16 +201,12 @@ procedure TForm1.Button1Click(Sender: TObject);
|
|||||||
var
|
var
|
||||||
s,x : String;
|
s,x : String;
|
||||||
begin
|
begin
|
||||||
PD.Copies := 4;
|
|
||||||
PD.FromPage := 1;
|
|
||||||
PD.ToPage := 5;
|
|
||||||
PD.MinPage := 1;
|
|
||||||
PD.MaxPage := 5;
|
|
||||||
PD.PrintRange := prAllPages;
|
|
||||||
//PD.Options := [poPageNums,poSelection,poPrintToFile];
|
|
||||||
if PD.Execute then
|
if PD.Execute then
|
||||||
begin
|
begin
|
||||||
UpdatePrinterInfo;
|
UpdatePrinterInfo;
|
||||||
|
if PD.Collate then AddInfo('Collate','true')
|
||||||
|
else
|
||||||
|
AddInfo('Collate','false');
|
||||||
if PD.PrintRange=prPageNums then x :='Pages range,';
|
if PD.PrintRange=prPageNums then x :='Pages range,';
|
||||||
if PD.PrintRange=prSelection then x :='Selection,';
|
if PD.PrintRange=prSelection then x :='Selection,';
|
||||||
if PD.PrintToFile then x := x + ' ,PrintToFile,';
|
if PD.PrintToFile then x := x + ' ,PrintToFile,';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<PathDelim Value="/"/>
|
<PathDelim Value="\"/>
|
||||||
<Version Value="5"/>
|
<Version Value="5"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
@ -16,44 +16,45 @@
|
|||||||
<LazDoc Paths=""/>
|
<LazDoc Paths=""/>
|
||||||
<Units Count="4">
|
<Units Count="4">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<CursorPos X="41" Y="12"/>
|
<CursorPos X="1" Y="14"/>
|
||||||
<Filename Value="selectprinter.lpr"/>
|
<Filename Value="selectprinter.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<TopLine Value="1"/>
|
<TopLine Value="1"/>
|
||||||
<UnitName Value="selectprinter"/>
|
<UnitName Value="selectprinter"/>
|
||||||
<UsageCount Value="114"/>
|
<UsageCount Value="140"/>
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
<CursorPos X="17" Y="24"/>
|
<CursorPos X="29" Y="32"/>
|
||||||
<EditorIndex Value="0"/>
|
<EditorIndex Value="0"/>
|
||||||
<Filename Value="frmselprinter.pas"/>
|
<Filename Value="frmselprinter.pas"/>
|
||||||
<ComponentName Value="Form1"/>
|
<ComponentName Value="Form1"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
<ResourceFilename Value="frmselprinter.lrs"/>
|
<ResourceFilename Value="frmselprinter.lrs"/>
|
||||||
<TopLine Value="20"/>
|
<TopLine Value="21"/>
|
||||||
<UnitName Value="frmselprinter"/>
|
<UnitName Value="frmselprinter"/>
|
||||||
<UsageCount Value="114"/>
|
<UsageCount Value="140"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
<CursorPos X="15" Y="27"/>
|
<CursorPos X="10" Y="296"/>
|
||||||
<Filename Value="C:/lazarus/components/printers/win32/winprndialogs.inc"/>
|
<Filename Value="C:\lazarus\components\PRINTERS\WIN32\winprndialogs.inc"/>
|
||||||
<IsPartOfProject Value="True"/>
|
|
||||||
<TopLine Value="45"/>
|
|
||||||
<UnitName Value="text"/>
|
|
||||||
<UsageCount Value="60"/>
|
|
||||||
</Unit2>
|
|
||||||
<Unit3>
|
|
||||||
<CursorPos X="1" Y="1"/>
|
|
||||||
<Filename Value="C:/lazarus/components/printers/linux/cupsprndialogs.inc"/>
|
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<TopLine Value="1"/>
|
<TopLine Value="1"/>
|
||||||
<UnitName Value="text"/>
|
<UnitName Value="text"/>
|
||||||
<UsageCount Value="60"/>
|
<UsageCount Value="86"/>
|
||||||
|
</Unit2>
|
||||||
|
<Unit3>
|
||||||
|
<CursorPos X="1" Y="1"/>
|
||||||
|
<Filename Value="C:\lazarus\components\PRINTERS\LINUX\cupsprndialogs.inc"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<UnitName Value="text"/>
|
||||||
|
<UsageCount Value="86"/>
|
||||||
</Unit3>
|
</Unit3>
|
||||||
</Units>
|
</Units>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
|
<DestinationDirectory Value="$(TestDir)\publishedproject\"/>
|
||||||
<IgnoreBinaries Value="False"/>
|
<IgnoreBinaries Value="False"/>
|
||||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||||
@ -61,7 +62,7 @@
|
|||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="2">
|
<RequiredPackages Count="2">
|
||||||
@ -77,19 +78,30 @@
|
|||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="5"/>
|
<Version Value="5"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<SrcPath Value="$(LazarusDir)/lcl/;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)/"/>
|
<SrcPath Value="$(LazarusDir)\lcl\;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)\"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Parsing>
|
<Parsing>
|
||||||
<SyntaxOptions>
|
<SyntaxOptions>
|
||||||
|
<IncludeAssertionCode Value="True"/>
|
||||||
<DelphiCompat Value="True"/>
|
<DelphiCompat Value="True"/>
|
||||||
<UseAnsiStrings Value="True"/>
|
<UseAnsiStrings Value="True"/>
|
||||||
</SyntaxOptions>
|
</SyntaxOptions>
|
||||||
</Parsing>
|
</Parsing>
|
||||||
<CodeGeneration>
|
<CodeGeneration>
|
||||||
|
<Checks>
|
||||||
|
<IOChecks Value="True"/>
|
||||||
|
<RangeChecks Value="True"/>
|
||||||
|
<OverflowChecks Value="True"/>
|
||||||
|
<StackChecks Value="True"/>
|
||||||
|
</Checks>
|
||||||
<Generate Value="Faster"/>
|
<Generate Value="Faster"/>
|
||||||
</CodeGeneration>
|
</CodeGeneration>
|
||||||
<Linking>
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="True"/>
|
||||||
|
</Debugging>
|
||||||
<Options>
|
<Options>
|
||||||
<Win32>
|
<Win32>
|
||||||
<GraphicApplication Value="True"/>
|
<GraphicApplication Value="True"/>
|
||||||
@ -102,19 +114,25 @@
|
|||||||
<CompileReasons Run="False"/>
|
<CompileReasons Run="False"/>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<BreakPoints Count="1">
|
<Watches Count="6">
|
||||||
<Item1>
|
|
||||||
<Source Value="C:/lazarus/components/printers/win32/winprndialogs.inc"/>
|
|
||||||
<Line Value="20"/>
|
|
||||||
</Item1>
|
|
||||||
</BreakPoints>
|
|
||||||
<Watches Count="2">
|
|
||||||
<Item1>
|
<Item1>
|
||||||
<Expression Value="lpp.nCopies"/>
|
<Expression Value="lpp.nCopies"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
<Item2>
|
<Item2>
|
||||||
<Expression Value="DevMode^.dmCopies"/>
|
<Expression Value="DevMode^.dmCopies"/>
|
||||||
</Item2>
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Expression Value="PDev.DevMode.dmDriverExtra"/>
|
||||||
|
</Item3>
|
||||||
|
<Item4>
|
||||||
|
<Expression Value="AName"/>
|
||||||
|
</Item4>
|
||||||
|
<Item5>
|
||||||
|
<Expression Value="Pdev.name"/>
|
||||||
|
</Item5>
|
||||||
|
<Item6>
|
||||||
|
<Expression Value="pdev.name"/>
|
||||||
|
</Item6>
|
||||||
</Watches>
|
</Watches>
|
||||||
</Debugging>
|
</Debugging>
|
||||||
</CONFIG>
|
</CONFIG>
|
||||||
|
@ -127,9 +127,6 @@ begin
|
|||||||
fLastHandleType:=0;
|
fLastHandleType:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
procedure TWinPrinter.DoBeginDoc;
|
procedure TWinPrinter.DoBeginDoc;
|
||||||
var Inf: TDocInfo;
|
var Inf: TDocInfo;
|
||||||
begin
|
begin
|
||||||
@ -138,7 +135,6 @@ begin
|
|||||||
if fPrinterHandle=0 then
|
if fPrinterHandle=0 then
|
||||||
raise EPrinter.Create('Printer handle not defined');
|
raise EPrinter.Create('Printer handle not defined');
|
||||||
|
|
||||||
|
|
||||||
SetDC;
|
SetDC;
|
||||||
Canvas.Handle:=fDC;
|
Canvas.Handle:=fDC;
|
||||||
Canvas.Refresh;
|
Canvas.Refresh;
|
||||||
@ -175,36 +171,6 @@ begin
|
|||||||
AbortDoc(fDC);
|
AbortDoc(fDC);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(*
|
|
||||||
function TWinPrinter.GetDefaultPrinter : String;
|
|
||||||
var
|
|
||||||
PrtCount : DWORD;
|
|
||||||
Needed : DWORD;
|
|
||||||
Buffer : PChar;
|
|
||||||
DefaultPrinter : array[0..79] of Char;
|
|
||||||
begin
|
|
||||||
Result:='';
|
|
||||||
Needed:=0;
|
|
||||||
EnumPrinters(PRINTER_ENUM_DEFAULT,nil,5,nil,0,Needed,PrtCount);
|
|
||||||
if Needed>0 then
|
|
||||||
begin
|
|
||||||
GetMem(Buffer,Needed);
|
|
||||||
try
|
|
||||||
if EnumPrinters(PRINTER_ENUM_DEFAULT,nil,5,Buffer,Needed,Needed,PrtCount) then
|
|
||||||
Result := String(PPRINTER_INFO_5(Buffer)^.pPrinterName);
|
|
||||||
finally
|
|
||||||
FreeMem(Buffer);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
GetProfileString(PChar('windows'),PChar('device'),PChar(''),DefaultPrinter,SizeOf(DefaultPrinter));
|
|
||||||
if pos(',',DefaultPrinter)<>0 then
|
|
||||||
Result:=Copy(DefaultPrinter,1,Pos(',',DefaultPrinter)-1);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
*)
|
|
||||||
|
|
||||||
//Enum all defined printers. First printer it's default
|
//Enum all defined printers. First printer it's default
|
||||||
procedure TWinPrinter.DoEnumPrinters(Lst: TStrings);
|
procedure TWinPrinter.DoEnumPrinters(Lst: TStrings);
|
||||||
Var Flags : DWORD;
|
Var Flags : DWORD;
|
||||||
@ -348,18 +314,14 @@ begin
|
|||||||
FreeMem(Buffer);
|
FreeMem(Buffer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
//Retreive the code of papers
|
//Retreive the code of papers
|
||||||
|
|
||||||
|
|
||||||
FillChar(ArPapers,SizeOf(ArPapers),0);
|
FillChar(ArPapers,SizeOf(ArPapers),0);
|
||||||
PaperC:=DeviceCapabilities(PChar(Pdev.Name),PCHar(PDev.Port),
|
PaperC:=DeviceCapabilities(PChar(Pdev.Name),PCHar(PDev.Port),
|
||||||
DC_PAPERS,@ArPapers,nil);
|
DC_PAPERS,@ArPapers,nil);
|
||||||
if PaperC<=0 then raise EPrinter.CreateFmt('DoEnumPapers<DC_PAPERS> error : %d, (%s)',[GetLastError,SysErrorMessage(GetLastError)]);
|
if PaperC<=0 then raise EPrinter.CreateFmt('DoEnumPapers<DC_PAPERS> error : %d, (%s)',[GetLastError,SysErrorMessage(GetLastError)]);
|
||||||
for i:=0 to PaperC-1 do
|
for i:=0 to PaperC-1 do
|
||||||
Lst.Objects[i]:=TObject(Pointer(Integer(ArPapers[i])));
|
Lst.Objects[i]:=TObject(ptrint(ArPapers[i]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TWinPrinter.DoGetDefaultPaperName: string;
|
function TWinPrinter.DoGetDefaultPaperName: string;
|
||||||
@ -372,7 +334,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
PDev:=TPrinterDevice(Printers.Objects[PrinterIndex]);
|
PDev:=TPrinterDevice(Printers.Objects[PrinterIndex]);
|
||||||
|
|
||||||
i:=PaperSize.SupportedPapers.IndexOfObject(TObject(Pointer(Integer(PDev.DefaultPaper))));
|
i:=PaperSize.SupportedPapers.IndexOfObject(TObject(ptrint(PDev.DefaultPaper)));
|
||||||
if i<>-1 then
|
if i<>-1 then
|
||||||
Result:=PaperSize.SupportedPapers.Strings[i];
|
Result:=PaperSize.SupportedPapers.Strings[i];
|
||||||
end;
|
end;
|
||||||
@ -394,7 +356,7 @@ begin
|
|||||||
if i<>-1 then
|
if i<>-1 then
|
||||||
begin
|
begin
|
||||||
ClearDC;
|
ClearDC;
|
||||||
j:=SHORT(Pointer(PaperSize.SupportedPapers.Objects[i]));
|
j:=SHORT(ptrint(PaperSize.SupportedPapers.Objects[i]));
|
||||||
PDev.DevMode.dmPaperSize:=j;
|
PDev.DevMode.dmPaperSize:=j;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -470,7 +432,7 @@ begin
|
|||||||
PDev:=TPrinterDevice(Printers.Objects[PrinterIndex]);
|
PDev:=TPrinterDevice(Printers.Objects[PrinterIndex]);
|
||||||
|
|
||||||
ClearDC;
|
ClearDC;
|
||||||
PDev.DevMode.dmCopies:=aValue;
|
PDev.DevMode.dmCopies:=SHORT(aValue);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -570,7 +532,6 @@ begin
|
|||||||
finally
|
finally
|
||||||
FreeMem(InfoPrt);
|
FreeMem(InfoPrt);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TWinPrinter.GetCanPrint: Boolean;
|
function TWinPrinter.GetCanPrint: Boolean;
|
||||||
@ -579,12 +540,26 @@ begin
|
|||||||
Result := (DoGetPrinterState <> psStopped);
|
Result := (DoGetPrinterState <> psStopped);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWinPrinter.Properties;
|
function TWinPrinter.GetCanRenderCopies: Boolean;
|
||||||
|
var
|
||||||
|
pDev : TPrinterDevice;
|
||||||
|
Count : Integer;
|
||||||
|
begin
|
||||||
|
Result := inherited GetCanRenderCopies;
|
||||||
|
if (Printers.Count>0) then
|
||||||
|
begin
|
||||||
|
PDev:=TPrinterDevice(Printers.Objects[PrinterIndex]);
|
||||||
|
Count := DeviceCapabilities(PChar(Pdev.Name),PCHar(PDev.Port),DC_COPIES,nil,@PDev.DevMode);
|
||||||
|
Result := (Count > 1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TWinPrinter.AdvancedProperties;
|
||||||
begin
|
begin
|
||||||
PrinterProperties(TWin32WidgetSet(WidgetSet).AppHandle,fPrinterHandle);
|
PrinterProperties(TWin32WidgetSet(WidgetSet).AppHandle,fPrinterHandle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
INITIALIZATION
|
initialization
|
||||||
Printer:=TWinPrinter.Create;
|
Printer:=TWinPrinter.Create;
|
||||||
|
|
||||||
{end.}
|
{end.}
|
||||||
|
@ -30,7 +30,7 @@ uses
|
|||||||
Type
|
Type
|
||||||
TWinPrinter = class(TPrinter)
|
TWinPrinter = class(TPrinter)
|
||||||
private
|
private
|
||||||
fDefaultPrinter : String;
|
//fDefaultPrinter : String;
|
||||||
fLastHandleType : Byte; //0=None 1=IC 2=DC
|
fLastHandleType : Byte; //0=None 1=IC 2=DC
|
||||||
fDC : HDC;
|
fDC : HDC;
|
||||||
fPrinterHandle : THandle;
|
fPrinterHandle : THandle;
|
||||||
@ -67,6 +67,7 @@ Type
|
|||||||
function GetPrinterType: TPrinterType;override;
|
function GetPrinterType: TPrinterType;override;
|
||||||
function DoGetPrinterState: TPrinterState;override;
|
function DoGetPrinterState: TPrinterState;override;
|
||||||
function GetCanPrint: Boolean;override;
|
function GetCanPrint: Boolean;override;
|
||||||
|
function GetCanRenderCopies : Boolean;override;
|
||||||
function GetHandlePrinter : HDC;
|
function GetHandlePrinter : HDC;
|
||||||
procedure SetHandlePrinter(aValue : HDC);
|
procedure SetHandlePrinter(aValue : HDC);
|
||||||
public
|
public
|
||||||
@ -75,7 +76,7 @@ Type
|
|||||||
|
|
||||||
|
|
||||||
//Warning not portable functions here
|
//Warning not portable functions here
|
||||||
procedure Properties;
|
procedure AdvancedProperties;
|
||||||
//Warning it is a not potable property
|
//Warning it is a not potable property
|
||||||
property Handle : HDC read GetHandlePrinter write SetHandlePrinter;
|
property Handle : HDC read GetHandlePrinter write SetHandlePrinter;
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ var
|
|||||||
DeviceMode : THandle;
|
DeviceMode : THandle;
|
||||||
DevNames : PDevNames;
|
DevNames : PDevNames;
|
||||||
St : PChar;
|
St : PChar;
|
||||||
|
Extra,Size : Integer;
|
||||||
|
Fields : Dword;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
if not Assigned(Printer) then Exit;
|
if not Assigned(Printer) then Exit;
|
||||||
@ -26,19 +28,17 @@ begin
|
|||||||
hWndOwner:=TWin32WidgetSet(WidgetSet).AppHandle;
|
hWndOwner:=TWin32WidgetSet(WidgetSet).AppHandle;
|
||||||
rtMargin := fMargins;
|
rtMargin := fMargins;
|
||||||
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
||||||
|
Size := DeviceCapabilities(PChar(PDev.Name),PChar(PDev.Port),DC_SIZE,nil,nil);
|
||||||
DeviceMode:=GlobalAlloc(GHND,SizeOf(PDev.DevMode));
|
Extra := DeviceCapabilities(PChar(PDev.Name),PChar(PDev.Port),DC_EXTRA,nil,nil);
|
||||||
|
Fields := DeviceCapabilities(PChar(PDev.Name),PChar(PDev.Port),DC_FIELDS,nil,nil);
|
||||||
|
DeviceMode:=GlobalAlloc(GHND,Size + Extra);
|
||||||
try
|
try
|
||||||
DevMode:=PDeviceMode(GlobalLock(DeviceMode));
|
DevMode:=PDeviceMode(GlobalLock(DeviceMode));
|
||||||
try
|
try
|
||||||
//some plotters crash when DEVMODE contains other options set
|
CopyMemory(DevMode,@PDev.DevMode,SizeOf(PDev.DevMode));
|
||||||
//so only minimal options passed to print dialog
|
DevMode^.dmSize := Word(Size);
|
||||||
StrCopy(DevMode^.dmDeviceName,Pdev.DevMode.dmDeviceName);
|
DevMode^.dmDriverExtra := Word(Extra);
|
||||||
DevMode^.dmSize := Word(SizeOf(PDev.DevMode));
|
DevMode^.dmFields := Fields;
|
||||||
DevMode^.dmOrientation := Pdev.DevMode.dmOrientation;
|
|
||||||
DevMode^.dmFields := DM_ORIENTATION or DM_PAPERSIZE or DM_COPIES;
|
|
||||||
DevMode^.dmPaperSize := Pdev.DevMode.dmPaperSize;
|
|
||||||
DevMode^.dmCopies := Pdev.DevMode.dmCopies;
|
|
||||||
finally
|
finally
|
||||||
GlobalUnLock(DeviceMode);
|
GlobalUnLock(DeviceMode);
|
||||||
end;
|
end;
|
||||||
@ -72,20 +72,9 @@ begin
|
|||||||
try
|
try
|
||||||
//Set the properties for the selected printer
|
//Set the properties for the selected printer
|
||||||
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
||||||
|
CopyMemory(@PDev.DevMode,DevMode,sizeof(Pdev.DevMode));
|
||||||
PDev.DevMode.dmSize := SizeOf(PDev.DevMode);
|
PDev.DevMode.dmSize := SizeOf(PDev.DevMode);
|
||||||
StrCopy(@PDev.DevMode.dmDeviceName,DevMode^.dmDeviceName);
|
PDev.DevMode.dmDriverExtra := 0;
|
||||||
PDev.DevMode.dmOrientation := DevMode^.dmOrientation;
|
|
||||||
PDev.DevMode.dmFields := DevMode^.dmFields;
|
|
||||||
PDev.DevMode.dmPaperSize := DevMode^.dmPaperSize;
|
|
||||||
PDev.DevMode.dmPaperLength := DevMode^.dmPaperLength;
|
|
||||||
PDev.DevMode.dmPaperWidth := DevMode^.dmPaperWidth;
|
|
||||||
PDev.DevMode.dmScale := DevMode^.dmScale;
|
|
||||||
PDev.DevMode.dmCopies := DevMode^.dmCopies;
|
|
||||||
PDev.DevMode.dmPrintQuality := DevMode^.dmPrintQuality;
|
|
||||||
PDev.DevMode.dmColor := DevMode^.dmColor;
|
|
||||||
PDev.DevMode.dmDuplex := DevMode^.dmDuplex;
|
|
||||||
PDev.DevMode.dmYResolution := DevMode^.dmYResolution;
|
|
||||||
PDev.DevMode.dmTTOption := DevMode^.dmTTOption;
|
|
||||||
PDev.DefaultPaper := DevMode^.dmPaperSize;
|
PDev.DefaultPaper := DevMode^.dmPaperSize;
|
||||||
finally
|
finally
|
||||||
GlobalUnlock(lpp.hDevMode);
|
GlobalUnlock(lpp.hDevMode);
|
||||||
@ -110,6 +99,8 @@ var
|
|||||||
DeviceMode : THandle;
|
DeviceMode : THandle;
|
||||||
DevNames : PDevNames;
|
DevNames : PDevNames;
|
||||||
St : PChar;
|
St : PChar;
|
||||||
|
Extra,Size : Integer;
|
||||||
|
Fields : Dword;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
if not Assigned(Printer) then Exit;
|
if not Assigned(Printer) then Exit;
|
||||||
@ -124,19 +115,17 @@ begin
|
|||||||
hWndOwner:=TWin32WidgetSet(WidgetSet).AppHandle;
|
hWndOwner:=TWin32WidgetSet(WidgetSet).AppHandle;
|
||||||
|
|
||||||
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
||||||
|
Size := DeviceCapabilities(PChar(PDev.Name),PChar(PDev.Port),DC_SIZE,nil,nil);
|
||||||
DeviceMode:=GlobalAlloc(GHND,SizeOf(PDev.DevMode));
|
Extra := DeviceCapabilities(PChar(PDev.Name),PChar(PDev.Port),DC_EXTRA,nil,nil);
|
||||||
|
Fields := DeviceCapabilities(PChar(PDev.Name),PChar(PDev.Port),DC_FIELDS,nil,nil);
|
||||||
|
DeviceMode:=GlobalAlloc(GHND,Size + Extra);
|
||||||
try
|
try
|
||||||
DevMode:=PDeviceMode(GlobalLock(DeviceMode));
|
DevMode:=PDeviceMode(GlobalLock(DeviceMode));
|
||||||
try
|
try
|
||||||
//some plotters crash when DEVMODE contains other options set
|
CopyMemory(DevMode,@PDev.DevMode,SizeOf(PDev.DevMode));
|
||||||
//so only minimal options passed to print dialog
|
DevMode^.dmSize := Word(Size);
|
||||||
StrCopy(DevMode^.dmDeviceName,Pdev.DevMode.dmDeviceName);
|
DevMode^.dmDriverExtra := Word(Extra);
|
||||||
DevMode^.dmSize := Word(SizeOf(PDev.DevMode));
|
DevMode^.dmFields := Fields;
|
||||||
DevMode^.dmOrientation := Pdev.DevMode.dmOrientation;
|
|
||||||
DevMode^.dmFields := DM_ORIENTATION or DM_PAPERSIZE or DM_COPIES;
|
|
||||||
DevMode^.dmPaperSize := Pdev.DevMode.dmPaperSize;
|
|
||||||
DevMode^.dmCopies := Pdev.DevMode.dmCopies;
|
|
||||||
finally
|
finally
|
||||||
GlobalUnLock(DeviceMode);
|
GlobalUnLock(DeviceMode);
|
||||||
end;
|
end;
|
||||||
@ -166,20 +155,9 @@ begin
|
|||||||
try
|
try
|
||||||
//Set the properties for the selected printer
|
//Set the properties for the selected printer
|
||||||
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
||||||
|
CopyMemory(@PDev.DevMode,DevMode,sizeof(Pdev.DevMode));
|
||||||
PDev.DevMode.dmSize := SizeOf(PDev.DevMode);
|
PDev.DevMode.dmSize := SizeOf(PDev.DevMode);
|
||||||
StrCopy(@PDev.DevMode.dmDeviceName,DevMode^.dmDeviceName);
|
PDev.DevMode.dmDriverExtra := 0;
|
||||||
PDev.DevMode.dmOrientation := DevMode^.dmOrientation;
|
|
||||||
PDev.DevMode.dmFields := DevMode^.dmFields;
|
|
||||||
PDev.DevMode.dmPaperSize := DevMode^.dmPaperSize;
|
|
||||||
PDev.DevMode.dmPaperLength := DevMode^.dmPaperLength;
|
|
||||||
PDev.DevMode.dmPaperWidth := DevMode^.dmPaperWidth;
|
|
||||||
PDev.DevMode.dmScale := DevMode^.dmScale;
|
|
||||||
PDev.DevMode.dmCopies := DevMode^.dmCopies;
|
|
||||||
PDev.DevMode.dmPrintQuality := DevMode^.dmPrintQuality;
|
|
||||||
PDev.DevMode.dmColor := DevMode^.dmColor;
|
|
||||||
PDev.DevMode.dmDuplex := DevMode^.dmDuplex;
|
|
||||||
PDev.DevMode.dmYResolution := DevMode^.dmYResolution;
|
|
||||||
PDev.DevMode.dmTTOption := DevMode^.dmTTOption;
|
|
||||||
PDev.DefaultPaper := DevMode^.dmPaperSize;
|
PDev.DefaultPaper := DevMode^.dmPaperSize;
|
||||||
TWinPrinter(Printer).Handle := hDC;
|
TWinPrinter(Printer).Handle := hDC;
|
||||||
finally
|
finally
|
||||||
@ -204,11 +182,11 @@ var lpp : tagPD;
|
|||||||
DeviceMode : THandle;
|
DeviceMode : THandle;
|
||||||
DevNames : PDevNames;
|
DevNames : PDevNames;
|
||||||
St : PChar;
|
St : PChar;
|
||||||
Old : Integer;
|
Extra,Size : Integer;
|
||||||
|
Fields : Dword;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
if not Assigned(Printer) then Exit;
|
if not Assigned(Printer) then Exit;
|
||||||
Old := Copies;
|
|
||||||
if Printer.Printers.Count>0 then
|
if Printer.Printers.Count>0 then
|
||||||
begin
|
begin
|
||||||
FillChar(lpp,SizeOf(lpp),0);
|
FillChar(lpp,SizeOf(lpp),0);
|
||||||
@ -216,7 +194,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
lStructSize:=SizeOf(lpp);
|
lStructSize:=SizeOf(lpp);
|
||||||
hInstance:=LCLType.HInstance;
|
hInstance:=LCLType.HInstance;
|
||||||
Flags := PD_COLLATE or PD_USEDEVMODECOPIES or PD_RETURNDC;
|
Flags := PD_RETURNDC;
|
||||||
|
if Collate then Flags := Flags or PD_COLLATE;
|
||||||
case PrintRange of
|
case PrintRange of
|
||||||
prPageNums : Flags := Flags or PD_PAGENUMS;
|
prPageNums : Flags := Flags or PD_PAGENUMS;
|
||||||
prSelection : Flags := Flags or PD_SELECTION;
|
prSelection : Flags := Flags or PD_SELECTION;
|
||||||
@ -227,23 +206,23 @@ begin
|
|||||||
if not (poPageNums in Options) then Flags := Flags or PD_NOPAGENUMS;
|
if not (poPageNums in Options) then Flags := Flags or PD_NOPAGENUMS;
|
||||||
if not (poSelection in Options) then Flags := Flags or PD_NOSELECTION;
|
if not (poSelection in Options) then Flags := Flags or PD_NOSELECTION;
|
||||||
if (poPrintToFile in Options ) and (poDisablePrintToFile in Options) then Flags := Flags or PD_DISABLEPRINTTOFILE;
|
if (poPrintToFile in Options ) and (poDisablePrintToFile in Options) then Flags := Flags or PD_DISABLEPRINTTOFILE;
|
||||||
|
if (poHelp in Options) then Flags := Flags or PD_SHOWHELP;
|
||||||
|
if not (poWarning in Options) then Flags := Flags or PD_NOWARNING;
|
||||||
|
|
||||||
hWndOwner:=TWin32WidgetSet(WidgetSet).AppHandle;
|
hWndOwner:=TWin32WidgetSet(WidgetSet).AppHandle;
|
||||||
|
|
||||||
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
||||||
|
Size := DeviceCapabilities(PChar(PDev.Name),PChar(PDev.Port),DC_SIZE,nil,nil);
|
||||||
DeviceMode:=GlobalAlloc(GHND,SizeOf(PDev.DevMode));
|
Extra := DeviceCapabilities(PChar(PDev.Name),PChar(PDev.Port),DC_EXTRA,nil,nil);
|
||||||
|
Fields := DeviceCapabilities(PChar(PDev.Name),PChar(PDev.Port),DC_FIELDS,nil,nil);
|
||||||
|
DeviceMode:=GlobalAlloc(GHND,Size + Extra);
|
||||||
try
|
try
|
||||||
DevMode:=PDeviceMode(GlobalLock(DeviceMode));
|
DevMode:=PDeviceMode(GlobalLock(DeviceMode));
|
||||||
try
|
try
|
||||||
//some plotters crash when DEVMODE contains other options set
|
CopyMemory(DevMode,@PDev.DevMode,SizeOf(PDev.DevMode));
|
||||||
//so only minimal options passed to print dialog
|
DevMode^.dmSize := Word(Size);
|
||||||
DevMode^.dmSize := Word(SizeOf(PDev.DevMode));
|
DevMode^.dmDriverExtra := Word(Extra);
|
||||||
StrCopy(DevMode^.dmDeviceName,Pdev.DevMode.dmDeviceName);
|
DevMode^.dmFields := Fields;
|
||||||
DevMode^.dmOrientation := Pdev.DevMode.dmOrientation;
|
|
||||||
DevMode^.dmFields := DM_ORIENTATION or DM_PAPERSIZE or DM_COPIES;
|
|
||||||
DevMode^.dmPaperSize := Pdev.DevMode.dmPaperSize;
|
|
||||||
DevMode^.dmCopies := Copies;
|
|
||||||
finally
|
finally
|
||||||
GlobalUnLock(DeviceMode);
|
GlobalUnLock(DeviceMode);
|
||||||
end;
|
end;
|
||||||
@ -279,24 +258,18 @@ begin
|
|||||||
try
|
try
|
||||||
//Set the properties for the selected printer
|
//Set the properties for the selected printer
|
||||||
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
||||||
|
CopyMemory(@PDev.DevMode,DevMode,sizeof(Pdev.DevMode));
|
||||||
PDev.DevMode.dmSize := SizeOf(PDev.DevMode);
|
PDev.DevMode.dmSize := SizeOf(PDev.DevMode);
|
||||||
StrCopy(@PDev.DevMode.dmDeviceName,DevMode^.dmDeviceName);
|
PDev.DevMode.dmDriverExtra := 0;
|
||||||
PDev.DevMode.dmOrientation := DevMode^.dmOrientation;
|
if Printer.PaperSize.SupportedPapers.IndexOfObject(TObject(Integer(DevMode^.dmPaperSize))) <> -1
|
||||||
PDev.DevMode.dmFields := DevMode^.dmFields;
|
then
|
||||||
PDev.DevMode.dmPaperSize := DevMode^.dmPaperSize;
|
PDev.DefaultPaper := DevMode^.dmPaperSize
|
||||||
PDev.DevMode.dmPaperLength := DevMode^.dmPaperLength;
|
else
|
||||||
PDev.DevMode.dmPaperWidth := DevMode^.dmPaperWidth;
|
PDev.DefaultPaper := Integer(Printer.PaperSize.SupportedPapers.Objects[0]);
|
||||||
PDev.DevMode.dmScale := DevMode^.dmScale;
|
if nCopies=1 then Copies := DevMode^.dmCopies
|
||||||
PDev.DevMode.dmCopies := DevMode^.dmCopies;
|
|
||||||
PDev.DevMode.dmPrintQuality := DevMode^.dmPrintQuality;
|
|
||||||
PDev.DevMode.dmColor := DevMode^.dmColor;
|
|
||||||
PDev.DevMode.dmDuplex := DevMode^.dmDuplex;
|
|
||||||
PDev.DevMode.dmYResolution := DevMode^.dmYResolution;
|
|
||||||
PDev.DevMode.dmTTOption := DevMode^.dmTTOption;
|
|
||||||
PDev.DefaultPaper := DevMode^.dmPaperSize;
|
|
||||||
if DevMode^.dmCopies>1 then Copies := 1
|
|
||||||
else
|
else
|
||||||
Copies := Old;
|
Copies := nCopies;
|
||||||
|
Printer.Copies := Copies;
|
||||||
TWinPrinter(Printer).Handle := hDC;
|
TWinPrinter(Printer).Handle := hDC;
|
||||||
finally
|
finally
|
||||||
GlobalUnlock(lpp.hDevMode);
|
GlobalUnlock(lpp.hDevMode);
|
||||||
@ -305,9 +278,11 @@ begin
|
|||||||
|
|
||||||
PrintRange := prAllPages;
|
PrintRange := prAllPages;
|
||||||
PrintToFile := false;
|
PrintToFile := false;
|
||||||
|
Collate := false;
|
||||||
if (Flags and PD_SELECTION)>0 then PrintRange := prSelection;
|
if (Flags and PD_SELECTION)>0 then PrintRange := prSelection;
|
||||||
if (Flags and PD_PAGENUMS)>0 then PrintRange := prPageNums;
|
if (Flags and PD_PAGENUMS)>0 then PrintRange := prPageNums;
|
||||||
if (Flags and PD_PRINTTOFILE)>0 then PrintToFile := true;
|
if (Flags and PD_PRINTTOFILE)>0 then PrintToFile := true;
|
||||||
|
if (Flags and PD_COLLATE)>0 then Collate := true;
|
||||||
FromPage := Integer(nFromPage);
|
FromPage := Integer(nFromPage);
|
||||||
ToPage := Integer(nToPage);
|
ToPage := Integer(nToPage);
|
||||||
MinPage := Integer(nMinPage);
|
MinPage := Integer(nMinPage);
|
||||||
|
@ -49,7 +49,7 @@ const
|
|||||||
DM_COPIES = $100;
|
DM_COPIES = $100;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
Win32Orientations: array [TPrinterOrientation] of Integer = (
|
Win32Orientations: array [TPrinterOrientation] of SHORT = (
|
||||||
DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE, DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE);
|
DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE, DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE);
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +175,7 @@ type
|
|||||||
function DoGetPrinterState: TPrinterState; virtual;
|
function DoGetPrinterState: TPrinterState; virtual;
|
||||||
function GetPrinterType : TPrinterType; virtual;
|
function GetPrinterType : TPrinterType; virtual;
|
||||||
function GetCanPrint : Boolean; virtual;
|
function GetCanPrint : Boolean; virtual;
|
||||||
|
function GetCanRenderCopies : Boolean; virtual;
|
||||||
function GetXDPI: Integer; virtual;
|
function GetXDPI: Integer; virtual;
|
||||||
function GetYDPI: Integer; virtual;
|
function GetYDPI: Integer; virtual;
|
||||||
public
|
public
|
||||||
@ -204,7 +205,7 @@ type
|
|||||||
property Title: string read fTitle write fTitle;
|
property Title: string read fTitle write fTitle;
|
||||||
property PrinterType : TPrinterType read GetPrinterType;
|
property PrinterType : TPrinterType read GetPrinterType;
|
||||||
property CanPrint : Boolean read GetCanPrint;
|
property CanPrint : Boolean read GetCanPrint;
|
||||||
|
property CanRenderCopies : Boolean read GetCanRenderCopies;
|
||||||
property XDPI : Integer read GetXDPI;
|
property XDPI : Integer read GetXDPI;
|
||||||
property YDPI : Integer read GetYDPI;
|
property YDPI : Integer read GetYDPI;
|
||||||
end;
|
end;
|
||||||
@ -677,6 +678,11 @@ begin
|
|||||||
Result:=True;
|
Result:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPrinter.GetCanRenderCopies: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=True;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TPaperSize }
|
{ TPaperSize }
|
||||||
|
|
||||||
function TPaperSize.GetDefaultPaperName: string;
|
function TPaperSize.GetDefaultPaperName: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user