Put a hold on xbrowses scope action (SOLVED)

Put a hold on xbrowses scope action (SOLVED)

Postby Marc Venken » Fri Oct 27, 2017 9:24 am

I want to put a timer or so on the execution of a scope in a Xbrowse.

Normal behavior is that when we scroll into a browse, the scope is always executed, and for large databases (or network trafic) it give a slowmotion.

I want the execution of the scope to happen if the browse stay on the same row for example 1 second, then the scope should happen.

In this case, when I scroll the database, the scope is only exucuted when I stay on the line where I want to see the selected data.
Last edited by Marc Venken on Sun Oct 29, 2017 7:17 pm, edited 1 time in total.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Put a hold on xbrowses scope action

Postby ukoenig » Fri Oct 27, 2017 10:32 am

Marc,

maybe not needed ?
Can You test it, if there is any difference ?

New FTDN May/Mayo 2016 (FWH 16.05)
Postby Antonio Linares » Mon Jul 04, 2016 10:11 pm


May 2016
========

* XBrowse:
New: DATA lFastDraw (default .F. )
When set to .T., screen rendering of the browse is very fast.
But this can be set to .T. only when (a) background color of
all the cells are the same as oBrw:nClrPane, (b) all columns
use oBrw:oFont, (c) every column contains either single line
text or a single bitmap. Programmer has to decide when to use
this switch.

regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Put a hold on xbrowses scope action

Postby Marc Venken » Fri Oct 27, 2017 10:48 am

Uwe,

I don't see any difference.

Thanks.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Put a hold on xbrowses scope action

Postby nageswaragunupudi » Sat Oct 28, 2017 2:09 pm

You need to use a timer in bChange method
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Put a hold on xbrowses scope action

Postby Marc Venken » Sun Oct 29, 2017 1:13 pm

Looking at some info about timers, I have this kind of solutions.

They do what I want (delay the update of child browses), but it think almost for sure that it is not fully programmaticaly correct.

Code: Select all  Expand view
// before calling the oDlg

   Define Timer oTimer Interval 10000 Action updatescreen(oBrw) OF oWnd
   Activate Timer oTimer

// insite the setup of the browse

   :bChange       := { || scopetimer(oBrw) }




function scopetimer(oBrw)
   local nDuration := Seconds()+2
   oTimer:deactivate()

   WHILE Seconds() < nDuration
     SysRefresh()
   END

   updatescreen()

   oTimer:Activate()
return nil

//  a second option I tried

function scopetimer1(oBrw)

   local oTmr, nStart := Seconds()

   DEFINE TIMER oTmr INTERVAL 10000 ;
      ACTION If( Seconds() - nStart > 2,( nStart := Seconds(), updatescreen()  ), )
   ACTIVATE TIMER oTmr

return nil

// a third option I tried

function scopetimer2(oBrw)
  local nDuration := Seconds()+2

  WHILE Seconds() < nDuration
    SysRefresh()
  END

  updatescreen()
return nil

function updatescreen()
   SET_SCOPE(oBrw2)
   ('foto')->(DBGOTOP())
   oBrw:refresh()
   oBrw2:Refresh()
   oBrw4:gotop()
   oBrw4:Refresh()
   oImage:Refresh()
   oImage2:Refresh()
   Oget:refresh()
   oGet2:refresh()
   //msginfo("Test")
return NIL
*/
 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Put a hold on xbrowses scope action

Postby nageswaragunupudi » Sun Oct 29, 2017 1:51 pm

Please try this sample.
Create the prg in \fwh\samples folder and build with buildh.bat
Code: Select all  Expand view
#include "fivewin.ch"

// EXECUTE IN FWH\SAMPLES FOLDER

REQUEST DBFCDX

static nSecs      := 0
static nDelay     := 1  // seconds
static oTimer
//----------------------------------------------------------------------------//

function Main()

   field STATE,CODE
   local oDlg, oStates, oCust

   // OPEN DBF AND SET SCOPES
   USE STATES NEW VIA "DBFCDX"
   USE CUSTOMER NEW VIA "DBFCDX"
   INDEX ON STATE TAG STATEM TO TMP MEMORY
   SET ORDER TO TAG STATEM
   GO TOP
   SELECT STATES
   SET RELATION TO CODE INTO CUSTOMER SCOPED
   GO TOP

   //
   DEFINE DIALOG oDlg SIZE 900,600 PIXEL TRUEPIXEL

   @ 20,20 XBROWSE oStates SIZE 250,-20 PIXEL OF oDlg ;
      DATASOURCE "STATES" AUTOCOLS ;
      CELL LINES NOBORDER

   WITH OBJECT oStates
      :bChange    := { || nSecs := SECONDS() }
      :CreateFromCode()
   END

   @ 20,250 XBROWSE oCust SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" COLUMNS "STATE","CITY","SALARY" ;
      CELL LINES NOBORDER

   oCust:CreateFromCode()

   ACTIVATE DIALOG oDlg ON INIT DlgInit( oDlg, oCust )

   CLOSE DATA

return nil

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

static function DlgInit( oDlg, oCust )

   DEFINE TIMER oTimer INTERVAL 1000 OF oDlg ACTION CustScope( oCust )
   oTimer:Activate()

return nil

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

static function CustScope( oCust )

   if nSecs > 0
      if SECONDS() - nSecs >= nDelay
         oCust:GoTop()
         oCust:Refresh()
         nSecs    := 0
      endif
   endif

return nil

//----------------------------------------------------------------------------//
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Put a hold on xbrowses scope action

Postby Marc Venken » Sun Oct 29, 2017 6:58 pm

Works perfectly !! Thank you.

I have a learning question :

I see that you use :

SET RELATION TO CODE INTO CUSTOMER SCOPED

and I use :

:bChange := { || SET_SCOPE(oBrw) }

Code: Select all  Expand view

STATIC FUNCTION SET_SCOPE(oBrw)
LOCAL cNName := fotoinde->code

DBSELECTAREA( "nofoto" )
("nofoto")->( ORDSCOPE(0, cNName ) )
("nofoto")->(ORDSCOPE(1, cNName ) )

RETURN NIL
 


Is there a advantage in one of the 2 ways ? Maybe mine is the older fasion of programming ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Put a hold on xbrowses scope action

Postby nageswaragunupudi » Sun Oct 29, 2017 7:01 pm

Scoped relation is simpler and faster. Also less code less bugs
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 90 guests