FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Comments and requests about TWBrowse
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Comments and requests about TWBrowse
Posted: Thu Jul 22, 2010 02:15 PM

include "fivewin.ch"

function main()

 local oWnd, oLbx

 SET DELETED ON
 SET EXCLUSIVE OFF
 use customer

 define window oWnd title "Test Browse"

 @ 0 , 0 listbox oLbx fields alias "customer" of oWnd

 oWnd:oClient:= oLbx

 activate window oWnd MAXIMIZED

return nil

Marco Boschi
info@marcoboschi.it
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Comments and requests about TWBrowse
Posted: Thu Jul 22, 2010 02:48 PM
Ok, now I can see the problem. But please test this new sample:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    USE CUSTOMER

    DEFINE DIALOG oDlg

    @ 0 , 0 LISTBOX oBrw FIELDS

    ACTIVATE DIALOG oDlg;
             ON INIT ( oDlg:Maximize(),;
                       oDlg:SetControl( oBrw ) );
             CENTER

    RETURN NIL


It doesn't show any refreshing slowness here. So the problem is not the browse at all.

EMG
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Comments and requests about TWBrowse
Posted: Thu Jul 22, 2010 04:36 PM

Enrico,
I've tested your last sample.
Slowness is less evident.

I propose to slightly modify your program to make it more like a real work situation.
I don't believe that in your network you have good performance again.

I'm not talking about a failure.

I want to know if is it possible to rearrange this excellent class to obtain better performance with a drastically reduce of traffic on network.

Problems perhaps are elsewhere.

I'm comparing software for viewing picture written by myself and other famous applications
even in this case there is a little difference in refresh rate

good evening

#include "Fivewin.ch"


FUNCTION MAIN()


    LOCAL oDlg, oBrw, i

    ANNOUNCE RDDSYS

    SET DELETED ON
    SET EXCLUSIVE OFF
    USE CUSTOMER EXCLUSIVE

   COPY TO custtemp

    FOR i := 1 TO 1000
        APPEND FROM custtemp
    NEXT i

    INDEX ON field->first TAG first TO customer
    INDEX ON field->last  TAG last  TO customer
    INDEX ON field->city  TAG city  TO customer
    INDEX ON field->state TAG state TO customer
    INDEX ON field->zip   TAG zip   TO customer

    USE
    USE customer SHARED
    SET INDEX TO customer

    DEFINE DIALOG oDlg

    @ 0 , 0 LISTBOX oBrw FIELDS

    ACTIVATE DIALOG oDlg;
             ON INIT ( oDlg:Maximize(),;
                       oDlg:SetControl( oBrw ) );
             CENTER

    RETURN NIL

INIT PROCEDURE RddInit
REQUEST DBFFPT
REQUEST DBFCDX
rddSetDefault( "DBFCDX" )

Marco Boschi
info@marcoboschi.it
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Comments and requests about TWBrowse
Posted: Thu Jul 22, 2010 10:04 PM

Ok, the difference seems to be the SHARED clause, that is expected. With SHARED clause I can see the slow refresh even without indexes. I don't know if TWBrowse can be improved but the major benefit would be in improving DBF's shared access speed, if it were possible.

EMG

Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Comments and requests about TWBrowse
Posted: Fri Jul 23, 2010 07:37 AM

Ok Enrico
Thanks

Marco Boschi
info@marcoboschi.it
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Comments and requests about TWBrowse
Posted: Fri Jul 23, 2010 01:11 PM
OK, Enrico, here is a better example. I have really slowed down the screen painting with a delay and you can watch it repaint one step at a time after you move another window over it. You also hear all the beeps. A log file will be written that shows all the records read during the repainting. And you can disable() or LockWindowUpdate() the control and test it that way too.

You will also see evidence that bSkip does have something to do with refreshing a browse.

James

Code (fw): Select all Collapse
// Test disabled TWBrowse for painting while disabled.
// Use with FWH\samples\customer.dbf file

#include "fivewin.ch"

function main()

   local oWnd, oLbx, oBar

   ferase("test02.log")

   use customer

   define window oWnd title "Test Browse"

   define buttonbar oBar of oWnd
   define button of oBar action oLbx:disable()
   define button of oBar action oLbx:enable()
   define button of oBar action writeFile("test02.log","-----------")

   define button of oBar action LOCKWINDOWUPDATE( oLbx:hWnd )
   define button of oBar action LOCKWINDOWUPDATE()

   @0,0 listbox oLbx fields first, last;
      alias "customer";
      of oWnd

   oLbx:bSkip:= {|nRecs| ( msgBeep(),sleep(100),sysrefresh(),logfile( "test02.log" , ;
     { recno() } ), customer->(dbskipper( nRecs)) ) }

   oWnd:oClient:= oLbx

   activate window oWnd 

return nil
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Comments and requests about TWBrowse
Posted: Fri Jul 23, 2010 01:23 PM
Enrico,

I don't know if TWBrowse can be improved but the major benefit would be in improving DBF's shared access speed, if it were possible.


Here is a possible solution. In the LostFocus() method, copy all visible records into a buffer array. Then during refresh if the control does not have focus() then repaint using the array, otherwise repaint by reading records from the source.

When the control gets focus, reset the lHasFocus variable to .t.

Code (fw): Select all Collapse
Method LostFocus()
   ::lHasFocus:=.f.
    // copy visible records to buffer array
return nil

Methd GotFocus()
  ::lHasFocus:=.t.
return nil

Method Paint()
   ...
   if ::lHasFocus
     // paint using records
   else
      // paint using buffer array
   endif
   ...
return nil


Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Comments and requests about TWBrowse
Posted: Mon Jul 26, 2010 08:20 AM

Enrico,
James's suggestion is very very interesting.
Thanks

Marco Boschi
info@marcoboschi.it
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Comments and requests about TWBrowse
Posted: Wed Jul 28, 2010 10:21 AM
Here is a possible solution. In the LostFocus() method, copy all visible records into a buffer array. Then during refresh if the control does not have focus() then repaint using the array, otherwise repaint by reading records from the source.

When the control gets focus, reset the lHasFocus variable to .t.

This is what I proposed for xbrowse in the derived class posted in page.1. Instead of copying to array and painting from array, I saved the browse screen to bitmap and restored while painting. When the browse gets focus, it is painted normally. This is even faster than saving into array and painting from array.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Comments and requests about TWBrowse
Posted: Wed Jul 28, 2010 12:37 PM

Excuse me,
in these days I'm under pressure.
I've forgot to tell you that I tested your samples
It's a valid solution except for a little visual effect
There is a little flickering in your sample and in this (rewritten by me) there are
other problems that I am not able to resolve.

This is the only one working solution at the moment.
In my opinion to load into an array only visible cells would be a first step to improve browsing classes

include "fivewin.ch"

xtranslate DelObj <o> => If <o> != nil; DeleteObject( <o> ); endif; <o> := nil

REQUEST HB_GT_GUI_DEFAULT

ANNOUNCE RDDSYS

FUNCTION MAIN()
LOCAL oDlg

LOCAL oBrw
LOCAL aRec := {}

LOCAL nIni
LOCAL nRig
LOCAL nFin
LOCAL nCur := 1

SET DELETED ON
SET EXCLUSIVE OFF
USE customer
SET INDEX TO customer

nRig := 20
nIni := 1
nFin := 1

DEFINE DIALOG oDlg RESOURCE "DIALOGO"

oBrw := TXBR3():Redefine( 101, , oDlg )

ACTIVATE DIALOG oDlg

RETURN NIL

CLASS TXBR3 FROM TWBROWSE

CLASSDATA lRegistered AS LOGICAL // used internally

DATA hSaveScr

METHOD Paint()
METHOD Destroy()

ENDCLASS

METHOD Paint() CLASS TXBR3

local aInfo

if ::hSaveScr != nil .and. GetFocus() != ::hWnd
aInfo := ::DispBegin()
DrawBitmap( ::hDC, ::hSaveScr, 0, 0 )
::DispEnd( aInfo )
else
Super:Paint()
DelObj ::hSaveScr
::hSaveScr := WndBitMap( ::hWnd )
endif

return nil

METHOD Destroy() CLASS TXBR3

DelObj ::hSaveScr

return Super:Destroy()

INIT PROCEDURE RddInit
REQUEST DBFFPT
REQUEST DBFCDX
rddSetDefault( "DBFCDX" )

Marco Boschi
info@marcoboschi.it
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Comments and requests about TWBrowse
Posted: Wed Jul 28, 2010 01:08 PM
Marco,

There is a little flickering in your sample and in this (rewritten by me) there are other problems that I am not able to resolve.


What other problems are you having?

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Comments and requests about TWBrowse
Posted: Wed Jul 28, 2010 02:59 PM
Code (fw): Select all Collapse
There is a little flickering in your sample

I knew this and also I thought this could be fixed. If in principle, this is taking us in the right direction avoiding re-reading data from source atleast when repainting in non-focused state, then we can proceed further to improve this.

Saving and restoring the bitmap is painting the saved image one pixel off from the original position. This can be fixed.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Comments and requests about TWBrowse
Posted: Tue Sep 18, 2012 03:25 PM
This solution in my opinion is good:

Code (fw): Select all Collapse
#include 'fivewin.ch'
#include 'xbrowse.ch'

#xtranslate DelObj <o> => If <o> != nil; DeleteObject( <o> ); endif; <o> := nil

CLASS TXBR3 FROM TXBROWSE

   CLASSDATA lRegistered AS LOGICAL // used internally

   DATA  hSaveScr

   METHOD Paint()
   METHOD Destroy()

ENDCLASS

METHOD Paint() CLASS TXBR3

   local aInfo

   if ::hSaveScr != nil .and. GetFocus() != ::hWnd
      aInfo := ::DispBegin()
      DrawBitmap( ::hDC, ::hSaveScr, 0, 0 )
      ::DispEnd( aInfo )
   else
      Super:Paint()
      DelObj ::hSaveScr
      ::hSaveScr  := WndBitMap( ::hWnd )
   endif


return nil

METHOD Destroy() CLASS TXBR3

   DelObj ::hSaveScr

return Super:Destroy()


The question is:
Since in a dialog I have other obiects... is it possible in Paint method to check Focus of entire dialog instead of TWBROWSE object?

King Regards
Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Comments and requests about TWBrowse
Posted: Wed Sep 19, 2012 09:39 AM

up

Marco Boschi
info@marcoboschi.it
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Comments and requests about TWBrowse
Posted: Wed Sep 19, 2012 09:50 AM
Marco,

Since in a dialog I have other obiects... is it possible in Paint method to check Focus of entire dialog instead of TWBROWSE object?


Do you mean this ?

if ::hSaveScr != nil .and. GetFocus() != ::hWnd // it was ::hWnd
regards, saludos

Antonio Linares
www.fivetechsoft.com