471,348 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Printing Problems

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

Dec 2 '05 #1
4 1434
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ML****@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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

Dec 2 '05 #2
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)

Dec 2 '05 #3
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).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ML****@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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)

Dec 2 '05 #4
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.

Dec 5 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Programatix | last post: by
reply views Thread by Programatix | last post: by
5 posts views Thread by Mark Preston | last post: by
3 posts views Thread by Grim Reaper | last post: by
1 post views Thread by G.Esmeijer | last post: by
4 posts views Thread by Arif | last post: by
4 posts views Thread by Tracey | last post: by
1 post views Thread by Dreamtime | last post: by
18 posts views Thread by Brett | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.