Can't show Print Dialog in vs2005 on Windows 7

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am running VS2005 on a Windows 7 64bit PC. In my app I show a print dialog so the user can select a printer. This worked fine on my old XP PC, but after copying the app to a new Windows 7 machine the print dialog is no longer displayed. If
I create a simple vs2010 c# app that just declares the print dialog and invokes .ShowDialog, it is displayed. If I convert the original app to VS2010 though, it still doesns work?
Here is the code:


<div style="color:Black;background-color:White; <pre>
PrintDialog dlgPrint = <span style="color:Blue; new PrintDialog();
dlgPrint.PrinterSettings = <span style="color:Blue; new PrinterSettings();

<span style="color:Blue; if (Common.gPrinterToUse == <span style="color:#A31515; "" || Common.gPrinterToUse == <span style="color:Blue; null)
{
<span style="color:Blue; if (dlgPrint.ShowDialog() == DialogResult.OK)
{
_printer = dlgPrint.PrinterSettings.PrinterName;
Common.gPrinterToUse = _printer;
}
<span style="color:Blue; else
{
<span style="color:Blue; return;
}
}
<span style="color:Blue; else
{
_printer = Common.gPrinterToUse;
}
[/code]

<br/>
If I step through the code, the if (dlgPrint.ShowDialog() == DialogResult.OK) statement always takes the false code path and the dialog is not displayed.
Any ideas?

Thanks

View the full article
 
Back
Top