Printer class: selection errors

Printer class: selection errors

Postby TimStone » Mon Apr 02, 2018 7:44 pm

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Printer class: selection errors

Postby Enrico Maria Giordano » Mon Apr 02, 2018 8:25 pm

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

Code: Select all  Expand view  RUN
#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
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Printer class: selection errors

Postby TimStone » Mon Apr 02, 2018 8:59 pm

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Printer class: selection errors

Postby Enrico Maria Giordano » Mon Apr 02, 2018 9:40 pm

I removed PREVIEW clause: still no errors clicking Cancel button.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Printer class: selection errors

Postby TimStone » Mon Apr 02, 2018 11:22 pm

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Printer class: selection errors

Postby dtussman » Tue Apr 03, 2018 10:56 pm

I always use this and it works:

PRINT oprn name pname from user
IF EMPTY( oprn:hdc )
RETURN nil
ENDIF
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Printer class: selection errors

Postby TimStone » Tue Apr 03, 2018 11:08 pm

Thanks ... works perfectly in this case.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 50 guests