Ejecutar Acción al Cerrar el Preview

Post Reply
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Ejecutar Acción al Cerrar el Preview

Post by leandro »

Buenos días para todos,

Requiero ejecutar una función al momento de cerrar el preview de la impresión, justo al momento en que se cierre la ventana.

De antemano gracias
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Ejecutar Acción al Cerrar el Preview

Post by jvtecheto »

leandro wrote:Buenos días para todos,

Requiero ejecutar una función al momento de cerrar el preview de la impresión, justo al momento en que se cierre la ventana.
Hola Leandro:

La clase TPreview tiene una data : lExit .T. when the preview window has exited

Saludos.

Jose
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Re: Ejecutar Acción al Cerrar el Preview ER

Post by leandro »

Si tienes razon, pero creo que hice la pregunta mal :(

Lo que pasa es que requiero ejecutar una acción, al momento de cerrar el preview, pero desde Easy Report.

Estuve mirando la clase en el método END, ER llama la función rpreview, la cual se encarga de crear el objeto con la información que viene en la data ::oPrn.

Code: Select all

      //Preview
      IF ::oPrn:lMeta = .T. .and. Empty( ::oPrn:cFile )

         IF ::lCheck = .T.

            ::oPrn:End()
            SYSREFRESH()

         ELSE

            IF ::lShowInfo = .T.
               ::oInfoDlg:End()
               ::lShowInfo := .F.
            ENDIF

            RPreview( ::oPrn )

         ENDIF

      ELSE

         PrintEnd()
         //::oPrn:End()

      ENDIF
 
Pero la funcion rpreview no retorna ninguna variable, y no se como capturar el objeto para luego si poder ejecutar la acción al momento de cerrar el preview.

Code: Select all

//----------------------------------------------------------------------------//

function RPreview( oDevice, oReport )

   local oPreview

   if bUserPreview == nil
      oPreview := TPreview():New( oDevice, oReport )
      oDevice:oPreview := oPreview
      oPreview:Activate()
   else
      Eval( bUserPreview, oDevice, oReport )
   endif

return nil
 
Alguien sabe como puedo lograr lo que quiero, de antemano gracias.
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Ejecutar Acción al Cerrar el Preview

Post by nageswaragunupudi »

Code: Select all

#include "fivewin.ch"
#include "report.ch"

REQUEST DBFCDX

function Main()

   local oRep, oFont

   SetCustomPrintPreview( { |oDevice,oReport| MyPreview( oDevice, oReport ) } )

   USE CUSTOMER NEW SHARED VIA "DBFCDX"
   SET FILTER TO RECNO() <= 20
   GO TOP

   DEFINE FONT oFont NAME "TAHOMA"  SIZE 0,-12
   REPORT oRep PREVIEW FONT oFont

   COLUMN TITLE "NAME" DATA FIELD->FIRST
   COLUMN TITLE "CITY" DATA FIELD->CITY

   ENDREPORT

   oRep:bInit := { || CUSTOMER->( DBGOTOP() ) }

   ACTIVATE REPORT oRep

   RELEASE FONT oFont

return nil

function MyPreview( oDevice, oReport )

   local oPreview

   oPreview := TPreview():New( oDevice, oReport )
   oDevice:oPreview := oPreview
   //oPreview:Activate()
   MyPreviewActivate( oPreview )

return nil

#define GO_POS      0
#define GO_UP       1
#define GO_DOWN     2
#define GO_LEFT     1
#define GO_RIGHT    2
#define GO_PAGE    .T.


function MyPreviewActivate( Self )

   local hWndMain

   if ::oWnd == nil
      return nil
   endif

   if ::bSetUp != nil
      Eval( ::bSetUp, Self, ::oWnd )
   endif

   ACTIVATE WINDOW ::oWnd MAXIMIZED ;
      ON RESIZE    ( ::PaintMeta(), ::ResizeListView() ) ;
      ON UP        ::VScroll( GO_UP )             ;
      ON DOWN      ::VScroll( GO_DOWN )           ;
      ON PAGEUP    ::VScroll( GO_UP, GO_PAGE)     ;
      ON PAGEDOWN  ::VScroll( GO_DOWN, GO_PAGE)   ;
      ON LEFT      ::HScroll( GO_LEFT )           ;
      ON RIGHT     ::HScroll( GO_RIGHT )          ;
      ON PAGELEFT  ::HScroll( GO_LEFT, GO_PAGE )  ;
      ON PAGERIGHT ::HScroll( GO_RIGHT, GO_PAGE ) ;
      VALID        ( ::oWnd:oIcon := nil       ,;
                     ::oFont:End()             ,;
                     ::oCursor:End()           ,;
                     ::oMeta1:End()            ,;
                     ::oMeta2:End()            ,;
                     ::oDevice:End()           ,;
                     ::oHand:End()             ,;
                     If( Empty( ::oImageList ),, ( ::oImageList:End(), ::oImageList := nil ) ),;
                     If( ! Empty( ::oImageListPages ), ::oImageListPages:End(),),;
                     ::oWnd := nil             ,;
                     ::oDevice:oPreview := nil ,;
                     ::lExit := .T. )

     if ::oDevice:lPrvModal
         if ::oWndMain == nil
            StopUntil( { || ::lExit } )
         else
            hWndMain    := WndMain():hWnd
            StopUntil( { || ::lExit .or. !IsWindow( hWndMain ) } )
         endif
     endif

     OnPreviewEnd( Self )

return nil

//----------------------------------------------------------------------------//

function OnPreviewEnd( oPreview )

   MsgInfo( "End of Preview" )

return nil

//----------------------------------------------------------------------------//


 
Regards

G. N. Rao.
Hyderabad, India
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Re: Ejecutar Acción al Cerrar el Preview

Post by leandro »

Mr. Nages, Thanks for answering

I will perform some tests and comment. :D
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Re: Ejecutar Acción al Cerrar el Preview

Post by leandro »

Mr Nages

With Easy Report it does not work.

I do not know the syntax for ER.

Code: Select all

//----------------------------------------------------------------------------//

PROC pFactura()
local oReport,Pagina:=nLinea := 1
local vTCRCua:=0,vTCRVal:=0
local vTCan:=vTHoj:=vTSub:=vTota:=0

uFec:=dtoc(date())
uTim:=subs(time(),1,8)

SetCustomPrintPreview( { |oDevice,oReport| MyPreview( oDevice, oReport ) } )

EASYREPORT oVRD NAME "C:\xpmake\report\FACTURAC.vrd" PREVIEW (.T.) //OF oDlg2

  IF oVRD:lDialogCancel = .T.
    RETURN( .F. )
  ENDIF

  PRINTAREA 1 OF oVRD
  PRINTAREA 2 OF oVRD
  PRINTAREA 5 OF oVRD
  PRINTAREA 6 OF oVRD

END EASYREPORT oVRD

return nil

//----------------------------------------------------------------------------//

function MyPreview( oDevice, oReport )

   local oPreview

   oPreview := TPreview():New( oDevice, oReport )
   oDevice:oPreview := oPreview
   //oPreview:Activate()
   MyPreviewActivate( oPreview )

return nil

#define GO_POS      0
#define GO_UP       1
#define GO_DOWN     2
#define GO_LEFT     1
#define GO_RIGHT    2
#define GO_PAGE    .T.

//----------------------------------------------------------------------------//

function MyPreviewActivate( Self )

   local hWndMain

   if ::oWnd == nil
      return nil
   endif
    /*
   if ::bSetUp != nil
      Eval( ::bSetUp, Self, ::oWnd )
   endif */ 

   ACTIVATE WINDOW ::oWnd MAXIMIZED ;
      ON RESIZE    ( ::PaintMeta(), ::ResizeListView() ) ;
      ON UP        ::VScroll( GO_UP )             ;
      ON DOWN      ::VScroll( GO_DOWN )           ;
      ON PAGEUP    ::VScroll( GO_UP, GO_PAGE)     ;
      ON PAGEDOWN  ::VScroll( GO_DOWN, GO_PAGE)   ;
      ON LEFT      ::HScroll( GO_LEFT )           ;
      ON RIGHT     ::HScroll( GO_RIGHT )          ;
      ON PAGELEFT  ::HScroll( GO_LEFT, GO_PAGE )  ;
      ON PAGERIGHT ::HScroll( GO_RIGHT, GO_PAGE ) ;
      VALID        ( ::oWnd:oIcon := nil       ,;
                     ::oFont:End()             ,;
                     ::oCursor:End()           ,;
                     ::oMeta1:End()            ,;
                     ::oMeta2:End()            ,;
                     ::oDevice:End()           ,;
                     ::oHand:End()             ,;
                     If( Empty( ::oImageList ),, ( ::oImageList:End(), ::oImageList := nil ) ),;
                     If( ! Empty( ::oImageListPages ), ::oImageListPages:End(),),;
                     ::oWnd := nil             ,;
                     ::oDevice:oPreview := nil ,;
                     ::lExit := .T. )

     if ::oDevice:lPrvModal
         if ::oWndMain == nil
            StopUntil( { || ::lExit } )
         else
            hWndMain    := WndMain():hWnd
            StopUntil( { || ::lExit .or. !IsWindow( hWndMain ) } )
         endif
     endif

     OnPreviewEnd( Self )

return nil

//----------------------------------------------------------------------------//

function OnPreviewEnd( oPreview )

   MsgInfo( "End of Preview" )

return nil

//----------------------------------------------------------------------------//

 
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
Post Reply