Objeto Printer
05/02/2003
0
Alguem sabe como controlar o tamanho do papel usando o objeto TPrinter?
Julio Pontes
Curtir tópico
+ 0
Responder
Posts
06/02/2003
Magoo
Uses Windows, . . . Printers;
procedure MudaTamPapel(PaperSize, Comp, Alt: integer);
var
ADevice, ADriver, APort: array[0..255] of char;
DeviceMode: THandle;
M: PDevMode;
s: string;
begin
S := Printer.Printers[Printer.PrinterIndex];
Printer.GetPrinter(ADevice, ADriver, APort, DeviceMode);
M := GlobalLock(DeviceMode);
try
if M <> nil then
begin
M^.dmFields := DM_PAPERSIZE;
if PaperSize = DMPAPER_USER then
M^.dmFields := M^.dmFields or DM_PAPERLENGTH or DM_PAPERWIDTH;
M^.dmPaperLength := Alt;
M^.dmPaperWidth := Comp;
M^.dmPaperSize := PaperSize;
Printer.SetPrinter(ADevice, ADriver, APort, DeviceMode);
end;
finally
GlobalUnlock(DeviceMode);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//-->> DEFINE O TAMANHO DO PAPEL
//----------------------- (COMP 25,00 cm - ALTURA 14,00 cm)
MudaTamPapel(DMPAPER_USER,2500,1400);
// Aqui você chama a Impressão . . . . . . . . .
//-->> VOLTA TAMANHO NORMAL
MudaTamPapel(DMPAPER_LETTER, 0, 0);
end;
procedure MudaTamPapel(PaperSize, Comp, Alt: integer);
var
ADevice, ADriver, APort: array[0..255] of char;
DeviceMode: THandle;
M: PDevMode;
s: string;
begin
S := Printer.Printers[Printer.PrinterIndex];
Printer.GetPrinter(ADevice, ADriver, APort, DeviceMode);
M := GlobalLock(DeviceMode);
try
if M <> nil then
begin
M^.dmFields := DM_PAPERSIZE;
if PaperSize = DMPAPER_USER then
M^.dmFields := M^.dmFields or DM_PAPERLENGTH or DM_PAPERWIDTH;
M^.dmPaperLength := Alt;
M^.dmPaperWidth := Comp;
M^.dmPaperSize := PaperSize;
Printer.SetPrinter(ADevice, ADriver, APort, DeviceMode);
end;
finally
GlobalUnlock(DeviceMode);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//-->> DEFINE O TAMANHO DO PAPEL
//----------------------- (COMP 25,00 cm - ALTURA 14,00 cm)
MudaTamPapel(DMPAPER_USER,2500,1400);
// Aqui você chama a Impressão . . . . . . . . .
//-->> VOLTA TAMANHO NORMAL
MudaTamPapel(DMPAPER_LETTER, 0, 0);
end;
Responder
Clique aqui para fazer login e interagir na Comunidade :)