Problem with PrintReport2 |
Post Reply |
Author | |
Mike Lewis
Groupie Joined: 29 April 2009 Status: Offline Points: 41 |
Post Options
Thanks(0)
Posted: 22 June 2010 at 7:26am |
I am seeing some unexpected behaviour when trying to print a report:
1. Call PrintReport, passing 0. Either choose a printer or keep the default. Prints the report as expected. 2. Programmatically change the default printer. 3. Call PrintReport2, passing False. This should print to the new default printer, but instead it prints to the printer chosen in Step 1. If I exit the application, re-start, and do steps 2 and 3 on their own, the program correctly prints to the new default printer. But when I do the steps in the order shown above, I get the behaviour I described. It's as if the control is remembering the printer that was chosen in PrintReport, and uses this to override the default printer in PrintReport2. The only way to "clear" this setting is to exit the program and re-start. Is this a bug? Or am I doing something wrong? I am using version 13.1. Thanks in advance. Mike |
|
Mike Lewis
Software Developer Edinburgh, Scotland |
|
Mike Lewis
Groupie Joined: 29 April 2009 Status: Offline Points: 41 |
Post Options
Thanks(0)
|
Did I explain this problem badly? I tried to list the steps needed to reproduce the problem.
Doesn't anyone have any ideas? |
|
Mike Lewis
Software Developer Edinburgh, Scotland |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi Mike,
What do you mean by "Programmatically change the default printer"
Or just copy and paste exact code in here and I will try at the office (tomorrow) and will report back what I found, OK?
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
Mike Lewis
Groupie Joined: 29 April 2009 Status: Offline Points: 41 |
Post Options
Thanks(0)
|
Thanks for the reply, Aaron.
When I said I "Programmatically change the default printer", I mean I call the SetDefaultPrinter() Windows API function, passing the name of the target printer. I know this works, because I have used it in other other parts of the application, and besides, I can see the new default printer in the Printer and Faxes folder within Windows. This is a simplified version of the code (in Visual Foxpro 9.0): * Current Windows default printer is "HP Laserjet" thisform.oleReportGrid.PrintReport(0) * This displays a printer dialogue, from which I click Cancel. It * then prints the report (as expected). SetDefaultPrinter("Amyuni Printer Driver") * This correctly makes Amyuni the new default printer thisform.oleReportGrid.PrintReport2(.F.) * This prints the report without a dialogue. I expect it to send the * printout to the Amyuni printer, but it still goes to the Laserjet. I hope this makes sense. Mike |
|
Mike Lewis
Software Developer Edinburgh, Scotland |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi Mike,
You are right, it doesn't select default printer with steps you mentioned. I did a very quick test but didn't get a chance to investigate why? I will try again and will get back to you.
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
Mike Lewis
Groupie Joined: 29 April 2009 Status: Offline Points: 41 |
Post Options
Thanks(0)
|
Thanks, Aaron. I appreciate your help.
Mike |
|
Mike Lewis
Software Developer Edinburgh, Scotland |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi Mike,
I did test again and it works as should. I downloaded a class somewhere to set default printer and added code to print RC before setting new default printer and added code to print RC after setting a new default printer:
It's created with VB6.0 but maybe you can translate it in your own language...
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
Mike Lewis
Groupie Joined: 29 April 2009 Status: Offline Points: 41 |
Post Options
Thanks(0)
|
Aaron,
I've been through your code, and as far as I can see it is doing exactly what I am doing. But yours works as expected and mine doesn't. I really can't figure out why. Never mind. I'll have to try to find a workaround. But thanks anyway for going to so much trouble to help me. Best wishes, Mike |
|
Mike Lewis
Software Developer Edinburgh, Scotland |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |