mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 00:39:44 +02:00
added winapi printer specific TWinPrinter(Printer).Handle from Olivier
git-svn-id: trunk@7094 -
This commit is contained in:
parent
4c93d064a5
commit
a94e69edd1
@ -40,6 +40,12 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TWinPrinter.GetHandlePrinter : HDC;
|
||||
begin
|
||||
SetIC;
|
||||
Result:=fDC;
|
||||
end;
|
||||
|
||||
function TWinPrinter.BaseDialogs(aFlag : DWORD):boolean;
|
||||
var lpp : tagPD;
|
||||
PDev : TPrinterDevice;
|
||||
@ -155,7 +161,7 @@ begin
|
||||
fDC:=CreateIC(PChar(PDev.Driver),PChar(PDev.Device),
|
||||
PChar(PDev.Port),@PDev.DevMode);
|
||||
if fDC=0 then
|
||||
raise EPrinter.Create('Invalide printer');
|
||||
raise EPrinter.Create(Format('Invalide printer (DC=%d Driver=%s Device=%s Port=%s)',[fDC,Pdev.Driver,PDev.Device,PDev.Port]));
|
||||
if Assigned(Canvas) then
|
||||
Canvas.Handle:=fDC;
|
||||
fLastHandleType:=1;
|
||||
@ -173,7 +179,7 @@ begin
|
||||
fDC:=CreateDC(PChar(PDev.Driver),PChar(PDev.Device),
|
||||
PChar(PDev.Port),@PDev.DevMode);
|
||||
if fDC=0 then
|
||||
raise EPrinter.Create('Invalide printer');
|
||||
raise EPrinter.Create(Format('Invalide printer (DC=%d Driver=%s Device=%s Port=%s)',[fDC,Pdev.Driver,PDev.Device,PDev.Port]));
|
||||
if Assigned(Canvas) then
|
||||
Canvas.Handle:=fDC;
|
||||
fLastHandleType:=2;
|
||||
@ -257,7 +263,7 @@ begin
|
||||
//Evaluate buffer size
|
||||
Needed:=0;
|
||||
EnumPrinters(Flags,nil,Level,nil,0,Needed,PrtCount);
|
||||
if Needed<>0 then
|
||||
if Needed>0 then
|
||||
begin
|
||||
GetMem(Buffer,Needed);
|
||||
try
|
||||
@ -270,15 +276,9 @@ begin
|
||||
end
|
||||
else
|
||||
begin
|
||||
LstStr:=TStringList.Create;
|
||||
try
|
||||
GetProfileString(PChar('windows'),PChar('device'),PChar(''),DefaultPrinter,SizeOf(DefaultPrinter));
|
||||
LstStr.CommaText:=DefaultPrinter;
|
||||
if LstStr.Count>0 then
|
||||
DefaultPrinter:=LstStr.Strings[0];
|
||||
finally
|
||||
LstStr.Free;
|
||||
end;
|
||||
GetProfileString(PChar('windows'),PChar('device'),PChar(''),DefaultPrinter,SizeOf(DefaultPrinter));
|
||||
if pos(',',DefaultPrinter)<>0 then
|
||||
DefaultPrinter:=Copy(DefaultPrinter,1,Pos(',',DefaultPrinter)-1);
|
||||
end;
|
||||
|
||||
Flags:=PRINTER_ENUM_CONNECTIONS or PRINTER_ENUM_LOCAL;
|
||||
@ -447,7 +447,6 @@ begin
|
||||
Result:=1;
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
function TWinPrinter.DoSetPrinter(aName: string): Integer;
|
||||
@ -537,3 +536,7 @@ INITIALIZATION
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -63,12 +63,17 @@ Type
|
||||
|
||||
function GetXDPI: Integer; override;
|
||||
function GetYDPI: Integer; override;
|
||||
|
||||
function GetHandlePrinter : HDC;
|
||||
public
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
|
||||
function PrintDialog : Boolean; override;
|
||||
function PrinterSetup : Boolean; override;
|
||||
|
||||
//Warning it is a not potable property
|
||||
property Handle : HDC read GetHandlePrinter;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
*****************************************************************************
|
||||
|
||||
Abstract:
|
||||
This unit provide an access at Printers spool and other functions for manage
|
||||
This unit provide an access at Printers spool and other functions for manage
|
||||
the printers on Win32
|
||||
|
||||
|
||||
Documentations
|
||||
- Wine project
|
||||
- Microsoft MSDN Web
|
||||
@ -40,7 +40,7 @@ const
|
||||
{$i winutilprnconst.inc}
|
||||
|
||||
LibWinSpool = 'winspool.drv';
|
||||
|
||||
|
||||
type
|
||||
PDevNames = ^tagDEVNAMES;
|
||||
tagDEVNAMES = record
|
||||
@ -51,7 +51,7 @@ type
|
||||
end;
|
||||
|
||||
TFcntHook = function(Wnd: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
|
||||
|
||||
|
||||
tagPD=packed Record
|
||||
lStructSize : DWORD;
|
||||
hWndOwner : HWND;
|
||||
@ -144,7 +144,7 @@ type
|
||||
pName : PChar;
|
||||
pComment : PChar;
|
||||
end;
|
||||
|
||||
|
||||
PPRINTER_INFO_2 = ^_PRINTER_INFO_2;
|
||||
_PRINTER_INFO_2 = Record
|
||||
pServerName : PChar;
|
||||
@ -208,10 +208,10 @@ Function EnumForms(
|
||||
hPrinter : THandle; // handle to printer object
|
||||
Level : DWORD; // data level
|
||||
pForm : Pointer; // form information buffer
|
||||
cbBuf : DWord; // size of form information buffer
|
||||
cbBuf : DWord; // size of form information buffer
|
||||
var pcbNeeded : DWORD; // bytes received or required
|
||||
var pcReturned: DWORD // number of forms received
|
||||
|
||||
|
||||
): BOOL; stdcall; external LibWinSpool name 'EnumFormsA';}
|
||||
|
||||
{Function not compatible with all versions of Windows
|
||||
@ -250,3 +250,4 @@ implementation
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user