Printer class: selection errors

Post Reply
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Printer class: selection errors

Post by TimStone »

This is from a client ... and I need to trap it.

Using the tPrinter class for a report:
1). Using PRINT oPrn NAME "Workorder Printing" FROM USER // Send to user selected printer
2).The printer selection dialog pops up.
3) Instead of selecting a printer, the user clicks the Cancel button
4). The program gets a Windows error that the program has stopped working.

How can I trap and respond to this cancel button ?

Please ... don't ask me why he does this. That is beyond me since he has many other options in the process where he can cancel, but he does it here ...
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Printer class: selection errors

Post by Enrico Maria Giordano »

The following sample doesn't error out here. Please change it to show the error.

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    @ 1, 1 BUTTON "Print";
           ACTION PRINT()

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


STATIC FUNCTION PRINT()

    LOCAL oPrn

    PRINT oPrn NAME "Test" FROM USER PREVIEW
        PAGE
            oPrn:Say( 0, 0, "Test" )
        ENDPAGE
    ENDPRINT

    RETURN NIL
EMG
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Printer class: selection errors

Post by TimStone »

Enrico Maria Giordano wrote:The following sample doesn't error out here. Please change it to show the error.

EMG
Remove PREVIEW, then when the printer selection dialog appears, hit Cancel.

If Cancel is selected, then oPrn is not created ( I assume ), so it's possible other actions involving oPrn would then fail. How can I trap for that Cancel ?


Sent from my iPhone using Tapatalk
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Printer class: selection errors

Post by TimStone »

OK ... It's just on one very complex invoice print routine.

I suppose it's time to go back and do a section by section "comment out" test to find where it creates the error ... and see if some of my code perhaps conflicts with the class.

Thanks for looking at that.

Of course I have no idea why the client is doing this ...

Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
dtussman
Posts: 78
Joined: Sat Jun 06, 2015 6:57 pm

Re: Printer class: selection errors

Post by dtussman »

I always use this and it works:

PRINT oprn name pname from user
IF EMPTY( oprn:hdc )
RETURN nil
ENDIF
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Printer class: selection errors

Post by TimStone »

Thanks ... works perfectly in this case.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
Post Reply