Printer selection
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Printer selection
Hi,
I'am still using FW1.9.5. In this version the TO clause doesn't work. I saw in the printer.prg source that it's looking at the WIN.INI file, and the printer aren't there in XP.
Is there a work-around? Is there maybe a function so I can change the default printer?
Thanks,
Marc
I'am still using FW1.9.5. In this version the TO clause doesn't work. I saw in the printer.prg source that it's looking at the WIN.INI file, and the printer aren't there in XP.
Is there a work-around? Is there maybe a function so I can change the default printer?
Thanks,
Marc
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Printer selection
It's time to upgrade to 32 bit. Anyway, this is a working function:
EMG
Code: Select all
function SetPrintDefault( cModel )
local cDriver := StrToken( GetProfString( "Devices", cModel, "" ), 1, "," )
local cPort := StrToken( GetProfString( "Devices", cModel, "" ), 2, "," )
WriteProfString( "Windows", "Device", cModel + ",", + cDriver + "," + cPort )
return nil
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Thanks, I now I have to move to 32bits, but this application is still in 16
It's working, but the problem stays.
As I already experience before. If I start the application, then change the defaultprinter, he program still print to to default printer as it was wen starting the program. I there a solution for this problem?
Thanks,
Marc
It's working, but the problem stays.
As I already experience before. If I start the application, then change the defaultprinter, he program still print to to default printer as it was wen starting the program. I there a solution for this problem?
Thanks,
Marc
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
It should not. The following sample works fine for me in 16 bit:Marc Vanzegbroeck wrote:It's working, but the problem stays.
As I already experience before. If I start the application, then change the defaultprinter, he program still print to to default printer as it was wen starting the program.
Code: Select all
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oPrn, oFnt
LOCAL nHStep, nVStep
SETPRINTDEFAULT( "Win2PDF" )
PRINT oPrn PREVIEW
DEFINE FONT oFnt NAME "Arial" SIZE 0, -10 OF oPrn
nHStep = oPrn:nHorzRes() / 80
nVStep = oPrn:nVertRes() / 66
PAGE
oPrn:Say( 0, 0, "This is a test", oFnt )
oPrn:Say( 1 * nVStep, 0, "This is a test", oFnt )
ENDPAGE
ENDPRINT
RELEASE FONT oFnt
RETURN NIL
function SetPrintDefault( cModel )
local cDriver := StrToken( GetProfString( "Devices", cModel, "" ), 1, "," )
local cPort := StrToken( GetProfString( "Devices", cModel, "" ), 2, "," )
WriteProfString( "Windows", "Device", cModel + ",", + cDriver + "," + cPort )
return nil
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Check if SetPrintDefault() really changes your default printer. If yes, your print have to necessarily go to that printer. Unless you issued SetPrintDefault() after PRINT command.
Did you try my sample as it is (changing the printer, of course)? Are you sure that the printer name you provided was correct? Copy and paste it from printers control panel just to be sure.
EMG
Did you try my sample as it is (changing the printer, of course)? Are you sure that the printer name you provided was correct? Copy and paste it from printers control panel just to be sure.
EMG
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Enrico,
SetPrintDefault() really change my defaultprinter. This is not the problem. As I already told in my previous message. If I launch the program, than change the default printer manualy (via printer configuration) and than print, the program print to the printer that was the default one BEFORE launching my program. So the SetPrintDefault() have also no effect.
Marc
SetPrintDefault() really change my defaultprinter. This is not the problem. As I already told in my previous message. If I launch the program, than change the default printer manualy (via printer configuration) and than print, the program print to the printer that was the default one BEFORE launching my program. So the SetPrintDefault() have also no effect.
Marc
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Marc,
>SetPrintDefault() really change my defaultprinter. This is not the problem. As I already told in my previous message. If I launch the program, than change the default printer manualy (via printer configuration) and than print, the program print to the printer that was the default one BEFORE launching my program. So the SetPrintDefault() have also no effect.<
When you say, "change the default printer manually (via the printer configuration" do you mean via the Windows Control Panel? If so, that is the way things are supposed to work. The same would be true if you called SetPrintDefault() from within the program--I expect. I have not used it, but I presume it is changing the Windows default printer.
When an app runs it picks up the current Windows default printer as defined in the Windows Control Panel. That printer is now the application's default printer until or unless it is changed from within the application. You can do this via the setPrinter() function which calls up the Windows common control to set the printer. This function is normally called from the File-Printer Setup menu. Note that this function only changes the application's printer not the Windows default printer.
Changing the Windows default printer from the Control Panel while a application is running will not change the application's current default printer. The application will pick up that printer the next time it is run, however.
Note: I suggest that you should never change the Windows default printer from within an application. This will probably confuse and irritate the user. If you have a need to default your application to the same printer each time it is run, you can get code to do this on my website on this page. I have not tested it under 16bit however. Look under the Downloads section for "Saving and restoring the application's printer."
http://ourworld.compuserve.com/homepage ... rogram.htm
I hope that helps.
James
>SetPrintDefault() really change my defaultprinter. This is not the problem. As I already told in my previous message. If I launch the program, than change the default printer manualy (via printer configuration) and than print, the program print to the printer that was the default one BEFORE launching my program. So the SetPrintDefault() have also no effect.<
When you say, "change the default printer manually (via the printer configuration" do you mean via the Windows Control Panel? If so, that is the way things are supposed to work. The same would be true if you called SetPrintDefault() from within the program--I expect. I have not used it, but I presume it is changing the Windows default printer.
When an app runs it picks up the current Windows default printer as defined in the Windows Control Panel. That printer is now the application's default printer until or unless it is changed from within the application. You can do this via the setPrinter() function which calls up the Windows common control to set the printer. This function is normally called from the File-Printer Setup menu. Note that this function only changes the application's printer not the Windows default printer.
Changing the Windows default printer from the Control Panel while a application is running will not change the application's current default printer. The application will pick up that printer the next time it is run, however.
Note: I suggest that you should never change the Windows default printer from within an application. This will probably confuse and irritate the user. If you have a need to default your application to the same printer each time it is run, you can get code to do this on my website on this page. I have not tested it under 16bit however. Look under the Downloads section for "Saving and restoring the application's printer."
http://ourworld.compuserve.com/homepage ... rogram.htm
I hope that helps.
James
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Enrico,
>This is not the behavior I observe in my tests. Did you try my sample? It prints to the new default printer, not to the old one.
As I said in my previous message, I hadn't tried your code. I just did, and surprisingly it does print to the new Windows default printer. It doesn't seem logical that it would. I just tried running an application, then changing the default printer via the Windows Control Panel and the application's default printer remains that same as it was.
Apparently, your code is triggering a notification to the application to change it's printer but Windows' setup doesn't. Very odd.
As I mentioned in my previous message I highly recommend against changing the Windows default printer from within an application. Users are not going to expect this and it will probably upset them. Personally, I would be upset if a program did this.
James
>This is not the behavior I observe in my tests. Did you try my sample? It prints to the new default printer, not to the old one.
As I said in my previous message, I hadn't tried your code. I just did, and surprisingly it does print to the new Windows default printer. It doesn't seem logical that it would. I just tried running an application, then changing the default printer via the Windows Control Panel and the application's default printer remains that same as it was.
Apparently, your code is triggering a notification to the application to change it's printer but Windows' setup doesn't. Very odd.
As I mentioned in my previous message I highly recommend against changing the Windows default printer from within an application. Users are not going to expect this and it will probably upset them. Personally, I would be upset if a program did this.
James
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
I strongly agree. It was only a possible workaround, a fast and dirty solution of the Marc problem.James Bott wrote:As I mentioned in my previous message I highly recommend against changing the Windows default printer from within an application. Users are not going to expect this and it will probably upset them. Personally, I would be upset if a program did this.
EMG