visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: General :: refreshing printer settings for an active application in win32 api


By: camellia (Asia)  Date: 15/07/2006 07:12:40  English  Points: 20 Status: Answered
Quality : Excellent
I'm using VC++ 6.0 (not .NET) to drive Word, Excel and PowerPoint
(through the MFC way). The app logic is to open a word instance (for
example) and then print a bunch of different documents.

Before printing each document, I will change the registry settings of
the printer (which affect the global printer settings so to speak) and hope
that each document will be printed with different settings

The problem I come across right now is, I found out that each Word
application instance will get from the os the global printer settings
at the time of application start and remember that for its whole life
span. Therefore, the print settings which I want to apply to a
particular document (within the same word application instance) can't
be enforced.

I've tried DevMode but some of the printer settings are really unique
and we don't have these insider information from the printer vendor.

So, my question: is there any win32 api functions (with sample codes)
that can enforce an active application to 'refresh' its printer
settings from the global
settings? Without going through to hack the DEVMODE fields?

Please let me know.

Thanks!
By: VGR Date: 17/07/2006 09:15:00 English  Type : Answer
Ok, I have no clear idea myself, but I will try to give out some useful documentation.

I suppose you already read this M$ KB entry so, you see, I guess you have to use DEVMODE, and I see that using it is not that difficult. Specifically :


About DEVMODE
Often, an element of the DEVMODE structure pointed to by pDevMode will be modified (instead of an element of PRINTER_INFO_n). When this is the case, the pDevMode->dmFields flags will tell the application which fields can be changed. Because this is given to you by GetPrinter(), you can check the dmFields flag before attempting the change.

Also, because modifying fields in the device-independent part of DEVMODE may also effect changes in the device-dependent part, you need to call DocumentProperties() before calling SetPrinter() in order to make a consistent DEVMODE structure for SetPrinter().



As far as your problem of "modifying the settings for all applications" stands, this page can also be helpful being read.

Good luck.
By: camellia Date: 17/07/2006 09:26:38 English  Type : Comment
VGR,

Thanks a lot!


Do register to be able to answer

EContact
browser fav
page generated in 291.412830 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page