mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 03:41:00 +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
|
||||
Left = 265
|
||||
Height = 356
|
||||
Height = 369
|
||||
Top = 181
|
||||
Width = 452
|
||||
HorzScrollBar.Page = 427
|
||||
VertScrollBar.Page = 301
|
||||
ActiveControl = ListBox1
|
||||
Caption = 'RawMode Print Test'
|
||||
ClientHeight = 356
|
||||
ClientHeight = 369
|
||||
ClientWidth = 452
|
||||
Constraints.MaxHeight = 400
|
||||
Constraints.MinHeight = 240
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '0.9.29'
|
||||
object Label1: TLabel
|
||||
Left = 15
|
||||
Height = 14
|
||||
Top = 5
|
||||
Width = 61
|
||||
Left = 12
|
||||
Height = 16
|
||||
Top = 8
|
||||
Width = 80
|
||||
Caption = 'Printers List:'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 11
|
||||
Height = 14
|
||||
Top = 150
|
||||
Width = 65
|
||||
Height = 16
|
||||
Top = 144
|
||||
Width = 80
|
||||
Caption = 'Text to print:'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 98
|
||||
Height = 60
|
||||
Top = 286
|
||||
Left = 96
|
||||
Height = 71
|
||||
Top = 292
|
||||
Width = 344
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
AutoSize = False
|
||||
@ -47,11 +48,12 @@ object Form1: TForm1
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
ItemHeight = 0
|
||||
TabOrder = 0
|
||||
TopIndex = -1
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 11
|
||||
Height = 25
|
||||
Top = 321
|
||||
Top = 334
|
||||
Width = 75
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
@ -61,8 +63,8 @@ object Form1: TForm1
|
||||
end
|
||||
object Memo1: TMemo
|
||||
Left = 11
|
||||
Height = 112
|
||||
Top = 168
|
||||
Height = 125
|
||||
Top = 162
|
||||
Width = 430
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Lines.Strings = (
|
||||
|
@ -87,7 +87,9 @@ begin
|
||||
exit;
|
||||
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.Title := Caption;
|
||||
Printer.RawMode := True;
|
||||
|
@ -139,10 +139,9 @@ begin
|
||||
|
||||
//Device is only 32 chars long,
|
||||
//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
|
||||
fDC:=CreateDC(PChar('WINSPOOL'),PChar(Printers[PrinterIndex]),nil,
|
||||
PDev.DevMode);
|
||||
fDC := CreateDC(PChar('WINSPOOL'),PChar(PDev.Name), nil, PDev.DevMode);
|
||||
|
||||
{Workaround (hack) for Lexmark 1020 JetPrinter (Mono)}
|
||||
if fDC=0 then
|
||||
@ -399,6 +398,8 @@ begin
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
Result := AnsiToUTF8(Result);
|
||||
end;
|
||||
|
||||
|
||||
@ -414,6 +415,7 @@ Var Flags : DWORD;
|
||||
DefaultPrinter : string;
|
||||
PDev : TPrinterDevice;
|
||||
TmpDevMode : PDeviceMode;
|
||||
PrtStr : string;
|
||||
begin
|
||||
{$IFDEF NOPRINTERS}
|
||||
Lst.Clear;
|
||||
@ -460,11 +462,12 @@ begin
|
||||
PDev.Device:='';
|
||||
PDev.DefaultPaper:=0;
|
||||
end;
|
||||
if AnsiCompareText(PDev.Name,DefaultPrinter)<>0 then
|
||||
Lst.AddObject(PDev.Name,PDev)
|
||||
PrtStr := AnsiToUTF8(PDev.Name);
|
||||
if AnsiCompareText(PrtStr,DefaultPrinter)<>0 then
|
||||
Lst.AddObject(PrtStr,PDev)
|
||||
else
|
||||
begin
|
||||
Lst.Insert(0,PDev.Name);
|
||||
Lst.Insert(0,PrtStr);
|
||||
Lst.Objects[0]:=PDev;
|
||||
end;
|
||||
Inc(InfoPrt,SizeOf(_PRINTER_INFO_2));
|
||||
|
Loading…
Reference in New Issue
Block a user