⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 改变打印的纸张大小.txt

📁 大量Delphi开发资料
💻 TXT
字号:
procedure TForm1.Button1Click(Sender: TObject);

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


     {Set to legal}

      pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;

      pDMode^.dmPaperSize := DMPAPER_LEGAL;


     {Set to custom size}

      pDMode^.dmFields := pDMode^.dmFields or 

                          DM_PAPERSIZE or

                          DM_PAPERWIDTH or

                          DM_PAPERLENGTH;

      pDMode^.dmPaperSize := DMPAPER_USER;

      pDMode^.dmPaperWidth := 100 {SomeValueInTenthsOfAMillimeter};

      pDMode^.dmPaperLength := 100 {SomeValueInTenthsOfAMillimeter};


     {Set the bin to use}

      pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;

      pDMode^.dmDefaultSource := DMBIN_MANUAL;


      GlobalUnlock(hDMode);

    end;

  end;

  Printer.PrinterIndex := Printer.PrinterIndex;

  Printer.BeginDoc;

  Printer.Canvas.TextOut(100,100, 'Test 1');

  Printer.EndDoc;

end;


*********************************************************************************************

procedure TForm1.Button1Click(Sender: TObject);

var

Device : array[0..255] of char;

Driver : array[0..255] of char;

Port   : array[0..255] of char;

hDMode : THandle;

PDMode : PDEVMODE;

begin

Never   Printer.PrinterIndex := Printer.PrinterIndex;

  Printer.GetPrinter(Device, Driver, Port, hDMode);

  if hDMode <> 0 then begin

    pDMode := GlobalLock(hDMode);

    if pDMode <> nil then begin


     {Set to legal}

      pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;

      pDMode^.dmPaperSize := DMPAPER_LEGAL;


     {Set to custom size}

      pDMode^.dmFields := pDMode^.dmFields or

                          DM_PAPERSIZE or

                          DM_PAPERWIDTH or

                          DM_PAPERLENGTH;

      pDMode^.dmPaperSize := DMPAPER_USER;

      pDMode^.dmPaperWidth := 100 {SomeValueInTenthsOfAMillimeter};

      pDMode^.dmPaperLength := 100 {SomeValueInTenthsOfAMillimeter};


     {Set the bin to use}

      pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;

      pDMode^.dmDefaultSource := DMBIN_MANUAL;


      GlobalUnlock(hDMode);

    end;

  end;

  Printer.PrinterIndex := Printer.PrinterIndex;

  Printer.BeginDoc;

  Printer.Canvas.TextOut(100,100, 'Test 1');

  Printer.EndDoc;

end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -