Comments and requests about TWBrowse

Re: Comments and requests about TWBrowse

Postby MarcoBoschi » Thu Jul 22, 2010 2: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
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Comments and requests about TWBrowse

Postby Enrico Maria Giordano » Thu Jul 22, 2010 2:48 pm

Ok, now I can see the problem. But please test this new sample:

Code: Select all  Expand view
#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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Comments and requests about TWBrowse

Postby MarcoBoschi » Thu Jul 22, 2010 4: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" )
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Comments and requests about TWBrowse

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Comments and requests about TWBrowse

Postby MarcoBoschi » Fri Jul 23, 2010 7:37 am

Ok Enrico
Thanks
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Comments and requests about TWBrowse

Postby James Bott » Fri Jul 23, 2010 1: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: Select all  Expand view
// 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Comments and requests about TWBrowse

Postby James Bott » Fri Jul 23, 2010 1: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: Select all  Expand view
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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Comments and requests about TWBrowse

Postby MarcoBoschi » Mon Jul 26, 2010 8:20 am

Enrico,
James's suggestion is very very interesting.
Thanks
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Comments and requests about TWBrowse

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Comments and requests about TWBrowse

Postby MarcoBoschi » 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" )
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Comments and requests about TWBrowse

Postby James Bott » Wed Jul 28, 2010 1: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Comments and requests about TWBrowse

Postby nageswaragunupudi » Wed Jul 28, 2010 2:59 pm

Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Comments and requests about TWBrowse

Postby MarcoBoschi » Tue Sep 18, 2012 3:25 pm

This solution in my opinion is good:

Code: Select all  Expand view
#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
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Comments and requests about TWBrowse

Postby MarcoBoschi » Wed Sep 19, 2012 9:39 am

up
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Comments and requests about TWBrowse

Postby Antonio Linares » Wed Sep 19, 2012 9: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() != ::oWnd:hWnd // it was ::hWnd
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

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