CANCELENABLE in DCPRINT

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

CANCELENABLE in DCPRINT

#1 Post by GeneB »

When preparing a long report for preview or print, what is the way to enable an exit button?

The documentation says that CANCELENABLE adds a dialog window during printing with a Cancel button. I don't get a dialog window other than the one from BusyMessage. Can CancelEnable and BusyMessage be used together?
The "x" in the upper right corner of the "BusyMessage" does not cancel the preparation of the report. The stripped down code is below.
Can someone please show me what I'm doing wrong? Is there a method of doing this
similar to DC_Working? Thanks in advance.

DCPRINT ON ;
PREVIEW ;
BUSYMESSAGE "Preparing Report" ;
CANCELENABLE

lOkToPrint := .T.

FOR i:=1 TO LEN(aLines)

lOkToPrint := DC_PRINTEROK()

IF !lOkToPrint
EXIT
ENDIF

@ nRow,nCol DCPRINT SAY aLines
nRow++
NEXT

DCPRINT OFF

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CANCELENABLE in DCPRINT

#2 Post by rdonnay »

Here's how to do this using your own dialog.
This way you can have it display anything you want, even a progress bar.

Code: Select all

#include "dcprint.ch"
#include "dcdialog.ch"

FUNCTION Main()

LOCAL GetList[0], lOkToPrint, aLines[50],  i, oDlg, oProgress

DCPRINT ON ;
PREVIEW

@ 0,0 DCSAY 'Preparing report...' SAYSIZE 0
@ 2,0 DCPROGRESS oProgress SIZE 50,1 PERCENT
@ 4,0 DCPUSHBUTTON CAPTION 'Cancel' SIZE 10,1.2 ACTION {||lOkToPrint := .f.}
DCREAD GUI FIT MODAL TITLE 'My report' EXIT PARENT @oDlg

lOkToPrint := .T.

AFill(aLines,'Some text')

FOR i := 1 TO LEN(aLines)

  DC_GetProgress( oProgress, i, Len(aLines))

  DC_CompleteEvents()
 
  IF !lOkToPrint
    EXIT
  ENDIF

  @ nRow,nCol DCPRINT SAY aLines[i]
  nRow++

NEXT

oDlg:destroy()

IF lOkToPrint

  DCPRINT OFF

ELSE

  DCPRINT ABORT

ENDIF

Return nil
The eXpress train is coming - and it has more cars.

Post Reply