Printing Problems

  • Thread starter Thread starter MLM450
  • Start date Start date
M

MLM450

I have an unmanaged C++ program that displays a printer dialog and then

asks my C# program to perform the printing operation. What printer info

do I pass to my C# program? It looks like I need to establish values in

the PrinterSettings property of a PrintDocument object. But how?


I think I should be able to use the print DC, but I don't see a way
to apply it to the PrinterSettings property.


I have tried passing the DEVMODE and DEVNAMES handles from the PRINTDLG

structure to use in the SetHdevmode() and SetHdevnames() functions -
it did not work.


Any ideas?


Thanks,
Mike
 
Mike,

What you should do is call your dialog, and then have it expose the
whatever properties were set. Then, what you do is create your
PrintDocument class, and set the properties on that, along with whatever
settings in the PrinterSettings that are appropriate.

Once you do that, you call Print. Print will then call the delegate
registered with the Print event on the PrintDocument class (you need to set
that up as well). It is in there that you perform your printing, drawing to
the Graphics instance passed in through the event args. As long as your
method wrapped by the delegate has access to the parameters set in your
printer dialog, you should have everything you need.

Hope this helps.
 
Thanks for the quick reply Nicholas.

Forgive me if this sounds like a stupid question, but can you expand on
what you mean by "expose whatever properties were set"? We are
using the PRINTDLG structure with the standard print dialog. Do you
mean I need to go through all the PRINTDLG, DEVMODE, and DEVNAMES items
and transfer all this information manually? (yuck)
 
Unfortunately, yes, that is exactly what I mean. You will have to store
that on some level, and then access it later from the delegate that handles
the actual printing (or before you start printing, depending on the
property).
 
Thanks for your help. I was afraid it would come to that. I was just
hoping someone would tell me there was a simpler way.
 
Back
Top