mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 19:39:18 +02:00
Printers, Win32, retrieve printer names as UTF8, issue #17022
git-svn-id: trunk@26980 -
This commit is contained in:
parent
730de2d0c6
commit
8d83a14a6d
@ -1,37 +1,38 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 265
|
Left = 265
|
||||||
Height = 356
|
Height = 369
|
||||||
Top = 181
|
Top = 181
|
||||||
Width = 452
|
Width = 452
|
||||||
HorzScrollBar.Page = 427
|
HorzScrollBar.Page = 427
|
||||||
VertScrollBar.Page = 301
|
VertScrollBar.Page = 301
|
||||||
|
ActiveControl = ListBox1
|
||||||
Caption = 'RawMode Print Test'
|
Caption = 'RawMode Print Test'
|
||||||
ClientHeight = 356
|
ClientHeight = 369
|
||||||
ClientWidth = 452
|
ClientWidth = 452
|
||||||
Constraints.MaxHeight = 400
|
Constraints.MaxHeight = 400
|
||||||
Constraints.MinHeight = 240
|
Constraints.MinHeight = 240
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
LCLVersion = '0.9.29'
|
LCLVersion = '0.9.29'
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
Left = 15
|
Left = 12
|
||||||
Height = 14
|
Height = 16
|
||||||
Top = 5
|
Top = 8
|
||||||
Width = 61
|
Width = 80
|
||||||
Caption = 'Printers List:'
|
Caption = 'Printers List:'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object Label2: TLabel
|
object Label2: TLabel
|
||||||
Left = 11
|
Left = 11
|
||||||
Height = 14
|
Height = 16
|
||||||
Top = 150
|
Top = 144
|
||||||
Width = 65
|
Width = 80
|
||||||
Caption = 'Text to print:'
|
Caption = 'Text to print:'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object Label3: TLabel
|
object Label3: TLabel
|
||||||
Left = 98
|
Left = 96
|
||||||
Height = 60
|
Height = 71
|
||||||
Top = 286
|
Top = 292
|
||||||
Width = 344
|
Width = 344
|
||||||
Anchors = [akLeft, akRight, akBottom]
|
Anchors = [akLeft, akRight, akBottom]
|
||||||
AutoSize = False
|
AutoSize = False
|
||||||
@ -47,11 +48,12 @@ object Form1: TForm1
|
|||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
TopIndex = -1
|
||||||
end
|
end
|
||||||
object Button1: TButton
|
object Button1: TButton
|
||||||
Left = 11
|
Left = 11
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 321
|
Top = 334
|
||||||
Width = 75
|
Width = 75
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
BorderSpacing.InnerBorder = 4
|
BorderSpacing.InnerBorder = 4
|
||||||
@ -61,8 +63,8 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object Memo1: TMemo
|
object Memo1: TMemo
|
||||||
Left = 11
|
Left = 11
|
||||||
Height = 112
|
Height = 125
|
||||||
Top = 168
|
Top = 162
|
||||||
Width = 430
|
Width = 430
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
Lines.Strings = (
|
Lines.Strings = (
|
||||||
|
@ -87,7 +87,9 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Printer.PrinterIndex := Listbox1.ItemIndex;
|
// on a freshly retrieved printer list, either method could
|
||||||
|
// be used to select a printer: SetPrinter or PrinterIndex
|
||||||
|
//Printer.PrinterIndex := Listbox1.ItemIndex;
|
||||||
Printer.SetPrinter(ListBox1.Items[Listbox1.ItemIndex]);
|
Printer.SetPrinter(ListBox1.Items[Listbox1.ItemIndex]);
|
||||||
Printer.Title := Caption;
|
Printer.Title := Caption;
|
||||||
Printer.RawMode := True;
|
Printer.RawMode := True;
|
||||||
|
@ -139,10 +139,9 @@ begin
|
|||||||
|
|
||||||
//Device is only 32 chars long,
|
//Device is only 32 chars long,
|
||||||
//if the Printername or share is longer than 32 chars, this will return 0
|
//if the Printername or share is longer than 32 chars, this will return 0
|
||||||
fDC:=CreateDC(nil,PChar(Printers[PrinterIndex]),nil, PDev.DevMode);
|
fDC := CreateDC(nil, PChar(PDev.Name), nil, PDev.DevMode);
|
||||||
if fDC=0 then
|
if fDC=0 then
|
||||||
fDC:=CreateDC(PChar('WINSPOOL'),PChar(Printers[PrinterIndex]),nil,
|
fDC := CreateDC(PChar('WINSPOOL'),PChar(PDev.Name), nil, PDev.DevMode);
|
||||||
PDev.DevMode);
|
|
||||||
|
|
||||||
{Workaround (hack) for Lexmark 1020 JetPrinter (Mono)}
|
{Workaround (hack) for Lexmark 1020 JetPrinter (Mono)}
|
||||||
if fDC=0 then
|
if fDC=0 then
|
||||||
@ -399,6 +398,8 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Result := AnsiToUTF8(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -414,6 +415,7 @@ Var Flags : DWORD;
|
|||||||
DefaultPrinter : string;
|
DefaultPrinter : string;
|
||||||
PDev : TPrinterDevice;
|
PDev : TPrinterDevice;
|
||||||
TmpDevMode : PDeviceMode;
|
TmpDevMode : PDeviceMode;
|
||||||
|
PrtStr : string;
|
||||||
begin
|
begin
|
||||||
{$IFDEF NOPRINTERS}
|
{$IFDEF NOPRINTERS}
|
||||||
Lst.Clear;
|
Lst.Clear;
|
||||||
@ -460,11 +462,12 @@ begin
|
|||||||
PDev.Device:='';
|
PDev.Device:='';
|
||||||
PDev.DefaultPaper:=0;
|
PDev.DefaultPaper:=0;
|
||||||
end;
|
end;
|
||||||
if AnsiCompareText(PDev.Name,DefaultPrinter)<>0 then
|
PrtStr := AnsiToUTF8(PDev.Name);
|
||||||
Lst.AddObject(PDev.Name,PDev)
|
if AnsiCompareText(PrtStr,DefaultPrinter)<>0 then
|
||||||
|
Lst.AddObject(PrtStr,PDev)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Lst.Insert(0,PDev.Name);
|
Lst.Insert(0,PrtStr);
|
||||||
Lst.Objects[0]:=PDev;
|
Lst.Objects[0]:=PDev;
|
||||||
end;
|
end;
|
||||||
Inc(InfoPrt,SizeOf(_PRINTER_INFO_2));
|
Inc(InfoPrt,SizeOf(_PRINTER_INFO_2));
|
||||||
|
Loading…
Reference in New Issue
Block a user