获取打印对话框的结果

Get the result of a PrintDialog

本文关键字:结果 对话框 打印 获取      更新时间:2023-10-16

好的,在我的程序中,我显示了一个printDialog,我希望能够知道用户是单击打印按钮还是取消按钮。在我看到的所有在线示例中,printDialog都有确定按钮,而不是打印按钮。

例如(来自 msdn 的代码):

System::Windows::Forms::DialogResult result = printDialog1->ShowDialog();
if ( result == ::DialogResult::OK )
{
   //printing code here
}

因此,如果没有确定按钮,显然此代码将无法正常工作。

有人知道如何判断是否单击了打印按钮吗?

"打印"按钮返回DialogResult::OK因此可以安全地检查该值。

事实上,从 CommonDialog 继承的任何对话框都将返回 OK 表示成功。