none
PageSetupDialog.AllowPrinter = true not work in Windows Vista

    Question

  • // The simple code to show PrintSetupDialog with printer change button:

    using (var dlg = new PageSetupDialog())

    {

    dlg.PageSettings = new System.Drawing.Printing.PageSettings();

    dlg.PrinterSettings = new System.Drawing.Printing.PrinterSettings();

    dlg.AllowPrinter = true;

    dlg.ShowDialog(this);

    }

     

    I see the different behaviour of this code in XP and Vista OSes.

    When run at XP OS - I see "Printer..." button, but when run at Vista OS - the "Printer..." button is not visible.

     

    How set  the "Printer..." button visible?

     

    Regards,

    Andrey Kondabarov

     

    Monday, April 28, 2008 10:11 AM

Answers

  • Hi Akond,

     

    Just as you said, it’s a different implementation of API between Vista and Windows XP. Actually, you can use your code under XP or earlier Windows editions correctly. But things have changed since Vista.

     

    To explain it in more detail, PageSetupDialog internally calls the PAGESETUPDLG structure, which helps to finish jobs on configuring printers. And the AllowPrinter property in C# is designed for manipulate PSD_DISABLEPRINTER flag in PAGESETUPDLG structure.

     

    Unfortunately, our developers did remove the “Printer…” button on PageSetupDlg for Windows Vista. This was done for specific reason. It is because they do not recommend switching printers from the page setup dialog, where there is some information in the page setup dialog which is printer specific.

     

    For more information about PageSetupDlg, please refer to the following link (you can find the explanation of obsolete flag PSD_DISABLEPRINTER):

    http://msdn.microsoft.com/en-us/library/ms646842(VS.85).aspx

     

    On the other hand, our developers recommend you to implement this functionality by using PrintDialog, which can work fine as you like.

     

    Here is a workaround for your problem, written with PrintDialog:

    Code Snippet

            // button1_Click event is responsible for change printers.

            private void button1_Click(object sender, EventArgs e)

            {

                PrintDialog printDialog = new PrintDialog();

     

                // Setting AllowSomePages to true allows you

                // to choose the printing page range.

                printDialog.AllowSomePages = true;

     

                // Show the help button of PrintDialog.

                printDialog.ShowHelp = true;

     

                printDialog.Document = new System.Drawing.Printing.PrintDocument();

     

                DialogResult result = printDialog.ShowDialog();

     

                if (result == DialogResult.OK)

                    printDialog.Document.Print();

            }

     

     

    Hope it helps. If there is anything unclear, please feel free to let me know.

     

    Best wishes,

    Jun Wang

     

     

    Friday, May 02, 2008 6:12 AM

All replies

  • Hi Akond,

     

    Just as you said, it’s a different implementation of API between Vista and Windows XP. Actually, you can use your code under XP or earlier Windows editions correctly. But things have changed since Vista.

     

    To explain it in more detail, PageSetupDialog internally calls the PAGESETUPDLG structure, which helps to finish jobs on configuring printers. And the AllowPrinter property in C# is designed for manipulate PSD_DISABLEPRINTER flag in PAGESETUPDLG structure.

     

    Unfortunately, our developers did remove the “Printer…” button on PageSetupDlg for Windows Vista. This was done for specific reason. It is because they do not recommend switching printers from the page setup dialog, where there is some information in the page setup dialog which is printer specific.

     

    For more information about PageSetupDlg, please refer to the following link (you can find the explanation of obsolete flag PSD_DISABLEPRINTER):

    http://msdn.microsoft.com/en-us/library/ms646842(VS.85).aspx

     

    On the other hand, our developers recommend you to implement this functionality by using PrintDialog, which can work fine as you like.

     

    Here is a workaround for your problem, written with PrintDialog:

    Code Snippet

            // button1_Click event is responsible for change printers.

            private void button1_Click(object sender, EventArgs e)

            {

                PrintDialog printDialog = new PrintDialog();

     

                // Setting AllowSomePages to true allows you

                // to choose the printing page range.

                printDialog.AllowSomePages = true;

     

                // Show the help button of PrintDialog.

                printDialog.ShowHelp = true;

     

                printDialog.Document = new System.Drawing.Printing.PrintDocument();

     

                DialogResult result = printDialog.ShowDialog();

     

                if (result == DialogResult.OK)

                    printDialog.Document.Print();

            }

     

     

    Hope it helps. If there is anything unclear, please feel free to let me know.

     

    Best wishes,

    Jun Wang

     

     

    Friday, May 02, 2008 6:12 AM
  • Unfortunately applications like Adobe Photoshop CS2 depend on the Printers button being available from with the Page Setup dialog for proper printing configuration.  I just migrated my software to an extremely fast Windows 7 64 bit Ultimate PC and now that I finally have Photoshop running fast I cannot print! 
    Tuesday, January 05, 2010 6:39 PM
  • The PrintDialog is designed primary to print (Title is Print), but not to select a printer for later use.

    What's about the situation where I have a batch-program doing the (automatic) print job, which has no UI and on the other hand a engineering program with a UI to configure the printer-settings and page-settings?

    On XP I used the PageSetupDialog for this job and all runs well.

    Regards

    Friedhelm

     

    Wednesday, March 24, 2010 10:42 AM
  • The PrintDialog has a different use case than the PageSettings, we should NOT use the PrintDialog to set an applications default printer, this is rediculous.

    Different applications require the ability to have their own default printer.

    What can we do to get this corrected? Rewrite our own dialog? Doesn't that defeat the purpose of the standard dialog? Vista and Windows 7 continually annoy the ____ out of me, decisions like this one are just stupid.

    Thanks Microsoft for screwing up our applications that worked on prior versions of windows and not giving us an alternative.


    -Brett
    Monday, May 03, 2010 7:25 AM
  • Hi Jun Wang, I am facing the same problem with Windows 7. I went through the link provided by you where they are saying that 'PSD_DISABLEPRINTER' flag has been obsolete. Don't you think by saying that this flag is obsolete, we can't disable the 'Printer...' button. I couldn't found any documentation saying that the button 'Printer...' itself is been deleted. In the provided link they haven't explored about why it has been obsolete? Do you have any link where they have clearly mentioned that the button itself is been deleted and that is why this flag is obsolete. Waiting for your quick response. Thanking you in advance. Regards, Sachin.
    Tuesday, December 06, 2011 9:52 AM