Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 30-06-2006
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Poder: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Como cambiar el tamaño de papel de la Impresora

Como cambiar el tamaño de papel de la Impresora

Ejemplo 1:

Código Delphi [-]
var
   Device : array[0..255] of char;
   Driver : array[0..255] of char;
   Port : array[0..255] of char;
   hDMode : THandle;
   PDMode : PDEVMODE;

begin
   Printer.PrinterIndex := Printer.PrinterIndex;
   Printer.GetPrinter(Device, Driver, Port, hDMode);
   if hDMode <> 0 then begin
      pDMode := GlobalLock(hDMode);
      if pDMode <> nil then begin
         pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
         pDMode^.dmPaperSize := DMPAPER_LEGAL;
         GlobalUnlock(hDMode);
     end;
   end;
   Printer.PrinterIndex := Printer.PrinterIndex;
   Printer.BeginDoc;
   Printer.Canvas.TextOut(100,100, 'Test 1');
   Printer.EndDoc;
end;

Ejemplo 2:

Código Delphi [-]
procedure TMain.PrintBtnClick(Sender: TObject);
var
   nCopies : Integer;
   ADevice, ADriver, APort: array [0..255] of Char;
   ADeviceMode: THandle;
   DevMode: PDevMode;
   Margins : TPoint;
Begin
   with Printer do begin
     GetPrinter (ADevice, ADriver, APort, ADeviceMode);
     SetPrinter (ADevice, ADriver, APort, 0); {force a Valid DevMode}
     GetPrinter (ADevice, ADriver, APort, ADeviceMode); {Now aDeviceMode is valid}
     DevMode := GlobalLock(ADeviceMode);
     if NOT Assigned(DevMode) then ShowMessage('Can''t set printer.')
     else Begin
        with DevMode^ do begin
          if CurLabel.Orientation = lrHorizontal then Begin
             dmOrientation := DMORIENT_LANDSCAPE;
             dmPaperLength := MulDiv(CurLabel.Width, 254, TWIPS);
             dmPaperWidth := MulDiv(CurLabel.Height, 254, TWIPS);
          End
          else Begin
             dmOrientation := DMORIENT_PORTRAIT;
             dmPaperLength := MulDiv(CurLabel.Height, 254, TWIPS);
             dmPaperWidth := MulDiv(CurLabel.Width, 254, TWIPS);
          End;
          dmFields := dmFields or DM_ORIENTATION;
          dmPaperSize := DMPAPER_USER;
          dmFields := dmFields or DM_PAPERSIZE or DM_PAPERLENGTH or DM_PAPERWIDTH;
        end;
        GlobalUnlock(ADeviceMode);
        SetPrinter(ADevice, ADriver, APort, ADeviceMode);
     end;
   end;
   nCopies := 1;
   Printer.Title := 'LabelWriter Output';
   Printer.BeginDoc; { Start Printing...}
   {...}
   Printer.EndDoc;
End;
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 15:02:54.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi