使用 Delphi VCL。当用户开始打印作业时,我会显示 TPrintDialog。
理想情况下,打印对话框应该显示用户上次使用的打印机名称、纸张尺寸和方向(我已保存)。但是,虽然我可以将方向传递给打印机并使其显示在对话框中,但我找不到让对话框显示默认打印机和纸张尺寸以外的任何内容的方法。
我可以设计一个看起来像打印对话框的自定义对话框,并以这种方式传递参数,但似乎应该有一种方法将这些参数传递给 TPrintDialog。
谢谢。
斯科特
好的,我不确定从 StackOverflow 的角度来看我是否正确地执行了此操作,如果没有,请原谅。
在 Remy 的帮助下,我已经解决了 VCL 工作的问题,但现在我仍停留在 FMX MacOS 版本上。
使用页面方向,我可以成功设置和获取方向,但它不会影响页面设置对话框中的方向或页面的实际打印方式。
以下是我所拥有的:
function getOrientation: string;
var
FPrintInfo: NSPrintInfo;
orientation: integer;
begin
result:='';
FPrintInfo := TNSPrintInfo.Wrap(TNSPrintInfo.OCClass.sharedPrintInfo);
FPrintInfo.retain;
PMGetOrientation(FPrintInfo.PMPageFormat, @orientation);
FPrintInfo.release;
if (orientation=1) or (orientation=3) then result:='portrait';
if (orientation=2) or (orientation=4) then result:='landscape';
end;
procedure setOrientation (const toSetS:string);
var
FPrintInfo: NSPrintInfo;
orientation: integer;
begin
if toSetS='portrait' then orientation:=1 else orientation:=2;
FPrintInfo := TNSPrintInfo.Wrap(TNSPrintInfo.OCClass.sharedPrintInfo);
FPrintInfo.retain;
PMSetOrientation(FPrintInfo.PMPageFormat,orientation,true);
FPrintInfo.release;
end;
谢谢。