bestlong 怕失憶論壇's Archiver

bestlong 發表於 2006-6-28 13:32

Delphi 開發 - 改變列印紙張大小

Delphi 開發 - 改變列印紙張大小
[code]
// 在執行打印前調用以下函數:
// x, y: 紙張尺寸, 單位是 0.1mm
procedure SetPaperSize(X, Y: Integer);
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
      if (x = 0) or (y = 0) then
      begin
        {設置合法的紙張大小}
        pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
        pDMode^.dmPaperSize := DMPAPER_FANFOLD_US; // 合法的紙張大小標示
      end
      else
      begin
        {設置用户自定義紙張}
        pDMode^.dmFields := pDMode^.dmFields or DM_PAPERSIZE or DM_PAPERWIDTH or DM_PAPERLENGTH;
        pDMode^.dmPaperSize := DMPAPER_USER; // 設置為用户自定義紙張標示
        pDMode^.dmPaperWidth := x; // 紙張寬度
        pDMode^.dmPaperLength := y; // 紙張長度
      end;
      {設定紙張来源}
      pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
      pDMode^.dmDefaultSource := DMBIN_MANUAL;

      GlobalUnlock(hDMode);
    end;
  end;
end;
[/code]

adonisbert 發表於 2007-2-13 15:21

請教...若要在 Win98 的平台下操作該如何實現?

因上述的 API 並無法運作於 Win98 的環境上,該如何在 Win98 上動態指定 自訂 格式的 Form 呢?

謝謝 ~~~
頁: [1]

Powered by Discuz! X1.5 Archiver   © 2001-2010 Comsenz Inc.