WAG: The program that is actually handling the print job is caching the last
used printer and using it.
Tracy


-----Original Message-----
From: Graham Brown
Sent: Friday, October 23, 2009 12:50 PM

Hi all
 
I've got some code which uses the set default printer windows API call.
This correctly changes the printer in the control panel printers applet and
the printer I've selected has a tick against it.
 
However if I either shellexecute print of any document or just right click
print from Windows explorer the output still goes to the original default
printer and not the one I've just set default to.
 
It's as though the change has been made but not applied or flushed in some
way.
 
This fails on both XP and Vista.
 
The test application I've written just has a combobox with printers listed
populated by aprinters.
In the interactive change event 
 
m.printer=thisform.PrinterCombo.value
set printer to name (m.printer)  
If !("98" $ Os())    && 98 evidently doesn't have the API.
           Declare Long GetLastError In WIN32API
           Declare Long SetDefaultPrinter In WINSPOOL.DRV String
pPrinterName
 
           nStat=SetDefaultPrinter(m.printer)

           If nStat != 0
 
            Wait Clear
           Endif
Endif

There is a print commandbutton which asks for the file to print which is a
pdf and does a simple shellexecute to do the print.
 
 
cParameters="SW_SHOWMINNOACTIVE"
Declare Integer ShellExecute IN SHELL32.Dll INTEGER nWinHandle, STRING
cOperation, STRING cFileName, STRING cParameters, STRING cDirectory,INTEGER
nShowWindow
ShellExecute(0, "Print", Alltrim(cnewName), "", "", 2)   && where
cNewName is the full path to a pdf in this instance.

Does anyone have any ideas please.
 
Regards
Graham
 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/001101ca5414$aff8fcd0$0feaf6...@com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to