Does PrinterSettings.GetHdevmode() have a bug?

Posted by Brandi on Stack Overflow See other posts from Stack Overflow or by Brandi
Published on 2010-03-12T23:55:22Z Indexed on 2010/03/12 23:57 UTC
Read the original article Hit count: 181

Filed under:
|
|
|
|

I would like to be able to change the printer properties without bringing up the printer properties window...

Using the DocumentProperties (imported from winspool.drv) function has so far failed, because while it is easy to suppress the dialog from showing up, it seems that the value returned by PrinterSettings.GetHdevmode() is not reflecting the PrinterSettings that is calling it, but instead the value from the previous printer properties returning OK. For example, this gives me the previous (wrong) values from the last call to the properties, instead of the values it should have from the PrinterSettings object:

IntPtr hdevmode = PrinterSettings.GetHdevmode(PrinterSettings.DefaultPageSettings);
PrinterSettings.SetHdevmode(hdevmode);
PrinterSettings.DefaultPageSettings.SetHdevmode(hdevmode);

So does GetHdevmode have a bug or is this what its supposed to do? Is there a C# work around for this or does anyone even have any information about it? I have been hard pressed even to find info on the topic.

Thanks in advance for any insight.

© Stack Overflow or respective owner

Related posts about c#

Related posts about printing