View Single Post
  #2 (permalink)  
Old 02-06-2008, 08:45 AM
Christoph Lindemann
 
Posts: n/a
Re: Changing a printers "global default" settings programatically on WinXP
Well, have you tried peeking at the documentation in the SDK? It sometimes
actually helps.

The keys to your success on setting the global and personal default
settings, are the level 8 and 9 PRINTER_INFO_* structures. Check out the
"SetPrinter" section and the "Per-User DEVMODE" section in the SDK.

Also try reading the "DocumentProperties" section. DocumentProperties has
nothing to do with setting default settings.
If you set duplex in the pDevModeInput it is also set in pDevModeOutput,
unless the printer does not support duplexing. By calling DocumentProperties
you give the driver the opportunity to fix/update/merge the changed members
with those of the driver's internal DEVMODE structure. The call is necessary
since some changes may not work correctly; the printer driver must be called
to correct the DEVMODE structure. When the document is about to be printed,
your application chould pass the merged DEVMODE structure to CreateDC

If you want to set the printer (while printing) to simplex, you should set
the DM_DUPLEX flag and specify DMDUP_SIMPLEX for the dmDuplex member. Or
else the driver will use it's driver internal default duplex setting (which
probably is simplex for standard printer drivers)

--
Christoph Lindemann


"Andrew Kennard" <b@a.com> wrote in message
news:%23hPxKi%23ZIHA.5784@TK2MSFTNGP03.phx.gbl...
> Hi all
>
> I've done a cross post on this reply tomyself(!) because I cant find an
> appropriate group to post this on.
>
> OK i've dug a bit futher an can confirm that when I use GetPrinter to get
> the PRINT_INFO_2 data from the printer is the duple mode is set the
> correct value is returned
>
> If it is not set the I change the DevMode.dmDuplex value and then pass it
> through DocumentProperties
>
> Move
> (DocumentProperties(0,hPrinter,AddressOf(sPrinterN ame),ppi2.pDevMode,ppi2.pDevMode,(DM_IN_BUFFER+DM_ OUT_BUFFER)))
> to iFlag
>
> When it comes out the other side of this dmDuplex is still set how I set
> it
>
> I then call SetPrinter with the full PRINT_INFO_2 data and it returns non
> zero ie succeeds
>
> Move (SetPrinter(hPrinter,2,pPI2_Data,0)) to iFlag
>
> BUT the duplex value when I go and check in the property panel of the
> printer has not changed ????
>
> Any help with this would be greatly appreciated !
>
> Thanks
>
> Andrew
>
>
> "Andrew Kennard" <b@a.com> wrote in message
> news:uK9izi1ZIHA.4172@TK2MSFTNGP02.phx.gbl...
>> Hi all
>>
>> Further to my other post I've found some more info on printer settings
>> specfically
>>
>> http://support.microsoft.com/kb/140285
>>
>> I've converted it so that it works in the language I am using (Visual
>> Dataflex) and it appears to be working in that non of the functions
>> return errors etc
>>
>> However having used it to "set" the duplex mode of the printer.
>>
>> When I go back into "Printers and Faxes" on XP and call up the printers
>> properties this setting has not changed ?
>>
>> Should this have worked ? ie am I doing something wrong ?
>>
>> Or can it not be done this way and I need to use another method ?
>>
>> Thanks in advance for your help
>>
>> Andrew
>>
>> PS I couldn't seem to find an appropraite newsgroup to post this on so I
>> hope these are the two closest !
>>

>
>



Reply With Quote