理由はわかりませんが、PrinterSetupDialogの後にPrintDialogを
呼び出すと用紙の長さが変わります。(正常になります。)
procedure TForm1.Button3Click(Sender: TObject);
var
ADevice : array[0..MAX_PATH-1] of Char;
ADriver : array[0..MAX_PATH-1] of Char;
APort : array[0..MAX_PATH-1] of Char;
ADeviceMode : THandle;
ADevMode : PDeviceMode;
begin
if PrinterSetupDialog1.Execute then begin
// 縦の長さを得る
Printer.GetPrinter(ADevice, ADriver, APort, ADeviceMode);
ADevMode := GlobalLock(ADeviceMode);
try
label1.Caption := inttostr(ADevMode^.dmPaperLength);
finally
GlobalUnlock(ADeviceMode);
end;
// 必要ないけどPrintDialogを開く
PrintDialog1.Execute;
// もう一度縦の長さを得る
Printer.GetPrinter(ADevice, ADriver, APort, ADeviceMode);
ADevMode := GlobalLock(ADeviceMode);
try
label4.Caption := inttostr(ADevMode^.dmPaperLength);
finally
GlobalUnlock(ADeviceMode);
end;
end;
end;
まあ、これでもいいかな?
|