FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Printer class: selection errors
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Printer class: selection errors
Posted: Mon Apr 02, 2018 07: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Printer class: selection errors
Posted: Mon Apr 02, 2018 08:25 PM
The following sample doesn't error out here. Please change it to show the error.

Code (fw): Select all Collapse
#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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Printer class: selection errors
Posted: Mon Apr 02, 2018 08: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Printer class: selection errors
Posted: Mon Apr 02, 2018 09:40 PM

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

EMG

Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Printer class: selection errors
Posted: 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
Posts: 102
Joined: Sat Jun 06, 2015 06:57 PM
Re: Printer class: selection errors
Posted: 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

Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Printer class: selection errors
Posted: 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

Continue the discussion