|
改变 PageSetupDialog 的标题文字(2) protected PageSetupDialog m_dialog; protected IntPtr m_handle = IntPtr.Zero; protected bool m_alreadySetup = false; private string title; public PageSetupDialogEx(PageSetupDialog dialog) { if (dialog == null) throw new ArgumentNullException("Must set a valid PageSetupDialog."); this.m_dialog = dialog; m_cbt = new LocalCbtHook(); m_cbt.WindowCreated += new CbtEventHandler(WndCreated); m_cbt.WindowActivated += new CbtEventHandler(WndActivated); } public PageSetupDialogEx(PageSetupDialog dialog, string title) : this(dialog) { this.title = title; } public string Title { get { return this.title; } set { this.title = value; } } // Show public DialogResult ShowDialog(IWin32Window owner) { // 调整一下单位,为什么要这么做,你应该知道的吧。 PageSettings ps = this.m_dialog.PageSettings; ps.Margins = PrinterUnitConvert.Convert(ps.Margins, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter); DialogResult dr; m_handle = IntPtr.Zero; m_cbt.Install(); dr = m_dialog.ShowDialog(owner); // 如果结果不是 OK,重新恢复 if (dr != DialogResult.OK) { ps.Margins = PrinterUnitConvert.Convert(ps.Margins, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display);
|