dcbrowse autorefresh

This forum is for eXpress++ general support.
Post Reply
Message
Author
bwolfsohn
Posts: 649
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

dcbrowse autorefresh

#1 Post by bwolfsohn »

Roger,

In the autorefresh clause of dcbrowse, is it possible to add an inactive nSeconds clause i.e. don't consider refreshing the browse unless there has been inactivity for nSeconds ?
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

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

Re: dcbrowse autorefresh

#2 Post by rdonnay »

I'm assuming you mean inactivity in the workstation in which the browse is displayed.

I think you can use the WHEN clause of AUTOREFRESH to do this and a variable that gets updated in a custom handler loop. I'll see if I can write a sample.
The eXpress train is coming - and it has more cars.

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

Re: dcbrowse autorefresh

#3 Post by rdonnay »

Here's the sample program:

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

STATIC snLastUpdate := 0

FUNCTION Main()

LOCAL GetList[0], oBrowse, aDir, i

aDir := Directory()

@ 0,0 DCBROWSE oBrowse DATA aDir SIZE 100, 20 ;
      AUTOREFRESH 1000 ;
        REFRESHBLOCK {|o|UpdateDirectory(o)} ;
        WHEN {||Seconds()-snLastUpdate < 15 }

DCBROWSECOL ELEMENT 1 HEADER 'File Name' WIDTH 10 PARENT oBrowse
DCBROWSECOL ELEMENT 2 HEADER 'File Size' WIDTH 10 PARENT oBrowse
DCBROWSECOL ELEMENT 3 HEADER 'File Date' WIDTH 10 PARENT oBrowse
DCBROWSECOL ELEMENT 4 HEADER 'File Time' WIDTH 10 PARENT oBrowse

DCREAD GUI FIT TITLE 'Browse Auto-Refresh Test' ;
   HANDLER myHandler

RETURN nil

* -----------

STATIC FUNCTION myHandler( nEvent, mp1 )

IF nEvent == xbeM_Motion
  snLastUpdate := Seconds()
ENDIF

RETURN DCGUI_NONE

* -----------

PROC appsys ; return

* -----------

STATIC FUNCTION UpdateDirectory( oBrowse )

wtf 'refreshing'

oBrowse:dataSource := Directory()
oBrowse:refresh()

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

bwolfsohn
Posts: 649
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: dcbrowse autorefresh

#4 Post by bwolfsohn »

Works great...

I made some changes to more easliy implement across all browses

Code: Select all

here's my autorefresh clause
AUTOREFRESH m->nBrowseRefresh WHEN {||myautorefresh() .AND. browse_not_active(snLastUpdate) }  

my handler clause
   HANDLER mybrowsehandler REFERENCE @snLastUpdate


**********************
function myautorefresh(aGetlist)
**********************
static slIsRefreshOn
IF slIsRefreshOn==nil
  slIsRefreshOn:=.t.
ENDIF
IF !aGetlist==nil
  slIsRefreshon:=!slIsRefreshOn
  DC_GetObject(aGetList,'REFRESHBUTTON'):setcaption('Turn Autorefresh '+IIF( slIsRefreshOn,"Off" ,"On" ))
ENDIF
return(slIsRefreshOn)

************************
FUNCTION myBrowseHandler( nEvent, mp1)
************************
IF nEvent == xbeM_Motion .OR. nEvent == xbeP_Keyboard
  snLastUpdate := Seconds()
ENDIF

RETURN DCGUI_NONE


**************************
function browse_not_active(snLastUpdate)
**************************
IF fexists('browsedebug.ovl')
  wtf Seconds()-snLastUpdate
ENDIF
return(Seconds()-snLastUpdate > m->nBrowseRefresh/100 )
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

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

Re: dcbrowse autorefresh

#5 Post by rdonnay »

Excellent!! :dance:
The eXpress train is coming - and it has more cars.

Post Reply