Page 1 of 1

Code is executing after ACTIVATE WINDOW

PostPosted: Sun Dec 23, 2012 10:32 am
by shri_fwh
Hi All,

I searched in the forum but I could not found the answer may be I could not co-relate with my problem. Basically I want to execute the code after a calling procedure execution is over. A calling procedure create and activate window ( not a dialog ) as WINDOW behavior it does not wait as dialog. I know we have VALID clause to execute the code after the WINDOW close (end) as per my need I can not use VALID clause. I am calling a procedure in the button action's block please see below. so do we have any solution apart from VALID clause ?
Thanks in advance.

Code: Select all  Expand view
  aoBTN[2]:bAction := <||

                        IF oRGSQry:vt_id == C_CHQ_RETURN_VT_ID
                           trv_dbrcpt( oRGSQry:vou_id )  // New Window Activates
                        ENDIF
                           --- below code should be execute after closing previous window
                           oRGSQry := oApp:gDBServer:Query( C_VT_REG( C_VR_VT_ID, C_VR_FROM_DATE, C_VR_TO_DATE  ) )
                           oBrwRGS:SetDolphin(oRGSQry)
                           oBrwRGS:Refresh()
                           --
                 
                       >

Thanks
Shridhar

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Sun Dec 23, 2012 12:48 pm
by Antonio Linares
Shridhar,

I am not sure about what you want to do exactly, but maybe you could use oWnd:bStart that is executed just once, when the window is initially shown

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Sun Dec 23, 2012 2:50 pm
by James Bott
Shirdhar,

Try the code below.

Regards,
James

Code: Select all  Expand view
 aoBTN[2]:bAction := {|oBrwRGS| ;
           IIF(oRGSQry:vt_id == C_CHQ_RETURN_VT_ID, ;
           trv_dbrcpt( oRGSQry:vou_id )), ;    // New Window Activates
           oRGSQry := oApp:gDBServer:Query( C_VT_REG( C_VR_VT_ID, C_VR_FROM_DATE, C_VR_TO_DATE  ) ),;
           oBrwRGS:SetDolphin(oRGSQry),;
           oBrwRGS:Refresh(),;
           }

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Sun Dec 23, 2012 10:04 pm
by Enrico Maria Giordano
Or you can use this:

Code: Select all  Expand view
ACTIVATE WINDOW oWnd;
         VALID ( oWnd := NIL, .T. )

STOPUNTIL( { || oWnd = NIL } )

// Here goes your code


EMG

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Mon Dec 24, 2012 2:31 am
by James Bott
Enrico,

Hey, I like that. Much easier.

Regards,
James

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Mon Dec 24, 2012 9:22 am
by shri_fwh
Hi All,

Thanks a lot..! for your great support.

Hi Antonio ,

Actually I want execute the code after a particular window operation is over. As WINDOW's behaviour the execute after ACTIVATE WINDOW that I do not need. Simply when we say ACTIVATE WINDOW oWnd it should wait till the Window is closed and continue with next code.

Hi Enrico ,

As I read in our forum the below function should not be used. Can we use this function in our code ? Please correct me if I am worng. Thanks in advance.

Code: Select all  Expand view

STOPUNTIL( { || oWnd = NIL } )
 


Thanks
Shridhar

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Mon Dec 24, 2012 10:16 am
by Enrico Maria Giordano
It's already used in rpreview.prg so yes, you can use it in your code.

EMG

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Mon Dec 24, 2012 2:55 pm
by shri_fwh
Hi Enrico ,

I tried but its not working and also when I closed entire application still the Window's task manager shows status is running.

Thanks
Shridhar

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Mon Dec 24, 2012 3:18 pm
by FranciscoA
Hi, if I understood, please look at this:
viewtopic.php?f=3&t=18270&start=0&hilit=oWnd%3Abpostend
Best regards

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Mon Dec 24, 2012 3:57 pm
by Enrico Maria Giordano
A working sample:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd

    DEFINE WINDOW oWnd

    ACTIVATE WINDOW oWnd;
             VALID ( oWnd := NIL, .T. )

    STOPUNTIL( { || oWnd = NIL } )

    ? "The end!"

    RETURN NIL


EMG

Re: Code is executing after ACTIVATE WINDOW

PostPosted: Tue Dec 25, 2012 4:34 am
by shri_fwh
Hi Enrico ,

Extremely sorry..! I had not added the VALID clause in the ACTIVATE WINDOW command.

Code: Select all  Expand view

 VALID ( oWnd := NIL, .T. )
 


Thanks
Shridhar