Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - Problem with PrintReport2
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem with PrintReport2

 Post Reply Post Reply
Author
Message
Mike Lewis View Drop Down
Groupie
Groupie


Joined: 29 April 2009
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mike Lewis Quote  Post ReplyReply Direct Link To This Post Topic: Problem with PrintReport2
    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
Back to Top
Mike Lewis View Drop Down
Groupie
Groupie


Joined: 29 April 2009
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mike Lewis Quote  Post ReplyReply Direct Link To This Post Posted: 29 June 2010 at 8:47am
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
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 29 June 2010 at 9:10am
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....
Back to Top
Mike Lewis View Drop Down
Groupie
Groupie


Joined: 29 April 2009
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mike Lewis Quote  Post ReplyReply Direct Link To This Post Posted: 29 June 2010 at 10:38am
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
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 30 June 2010 at 1:28pm
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....
Back to Top
Mike Lewis View Drop Down
Groupie
Groupie


Joined: 29 April 2009
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mike Lewis Quote  Post ReplyReply Direct Link To This Post Posted: 01 July 2010 at 3:44am
Thanks, Aaron. I appreciate your help.

Mike
Mike Lewis
Software Developer
Edinburgh, Scotland
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 02 July 2010 at 8:26am
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....
Back to Top
Mike Lewis View Drop Down
Groupie
Groupie


Joined: 29 April 2009
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mike Lewis Quote  Post ReplyReply Direct Link To This Post Posted: 05 July 2010 at 5:07am
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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.