Page 1 of 2

WBrowse changes the current file record by itself

Posted: Wed Feb 01, 2012 5:00 pm
by concentra
In some situations, WBrowse changes the current file record by itself...

Is this the expected behavior ?

In the sample, left click in 16 and after that type 11.

Harbour 3.1.0dev (Rev. 17102)
FiveWin Harbour October 2011

Code: Select all

#INCLUDE "FIVEWIN.CH"

FUNCTION MAIN()

   GenerateTestFile()

   cCodigo := "  "

   DEFINE WINDOW oDlg FROM 1,1 TO 20,60

   @ 1,5 GET oGetCodigo VAR cCodigo OF oDlg VALID( V_Codigo() ) SIZE 90, 22

   oBrw := TWBrowse():New( 5,5,400,150,,,,oDlg,,,,,,,,,,,,, "TESTBRW" )

   oBrw:SetCols( {{ || TESTBRW->CODIGO }}, {"Produto"}, {260} )

   ACTIVATE DIALOG oDlg

RETURN

/************************************************/
STATIC FUNCTION V_Codigo()
/************************************************/

   IF ! EMPTY(cCodigo) .AND. TESTBRW->( DBSEEK( cCodigo ) )
      ALERT( Recno() )
      oBrw:Refresh()
      ALERT( Recno() )
   ENDIF

   oGetCodigo:cText( "  " )

RETURN( .F. )

/************************************************/
STATIC FUNCTION GenerateTestFile()
/************************************************/

   aSTRU := { { "CODIGO", "C", 2, 0 } }
   DBCREATE( "TESTBRW.DBF", aSTRU )

   USE TESTBRW EXCLUSIVE
   INDEX ON FIELD->CODIGO TAG "COD"

   FOR I := 10 TO 25
      DBAPPEND()
      FIELD->CODIGO := STR(I,2)
   NEXT

   TESTBRW->( DBGOTOP() )

RETURN( .F. )
 
[[]] Maurício Ventura Faria

Re: WBrowse changes the current file record by itself

Posted: Wed Feb 01, 2012 6:48 pm
by Enrico Maria Giordano
I don't understand. Can you build a sample showing the problem, please?

EMG

Re: WBrowse changes the current file record by itself

Posted: Thu Feb 02, 2012 9:40 am
by concentra
Hi Enrico.
Enrico Maria Giordano wrote:I don't understand. Can you build a sample showing the problem, please?
The sample is part of the message...
The sample generates a DBF, indexes, and shows it in a wbrowse.
Run the sample, click on record showing 16 ( 7th record ) and then type 11 that seeks "11" in DBF that is record 2.
Before a wbrowse:refresh() the DBF is on record 2 what is OK and after the wbrowse:refresh() the DBF is on record 7... To me this seems not Ok.

[[]]
Maurício Ventura Faria

Re: WBrowse changes the current file record by itself

Posted: Thu Feb 02, 2012 9:43 am
by Enrico Maria Giordano
Your sample shows 2 and 2 here using FWH 11.11.

EMG

Re: WBrowse changes the current file record by itself

Posted: Thu Feb 02, 2012 10:32 am
by concentra
Enrico Maria Giordano wrote:Your sample shows 2 and 2 here using FWH 11.11
Ok. I am using October 2011 version...
What version of Harbour ?
May I send you my EXE in order to you test ? And could you send me yours ?
The problem doesn't occur all the time...

Re: WBrowse changes the current file record by itself

Posted: Thu Feb 02, 2012 10:34 am
by concentra
Enrico Maria Giordano wrote:Your sample shows 2 and 2 here using FWH 11.11.
If you repeat the process of clicking and typing a few times does the problem shows ?
Thanks for your help !

Re: WBrowse changes the current file record by itself

Posted: Thu Feb 02, 2012 10:53 am
by concentra
And I compiled it with xHarbour.com commercial version and the problem is still there...

Re: WBrowse changes the current file record by itself

Posted: Thu Feb 02, 2012 10:57 am
by Enrico Maria Giordano
concentra wrote:If you repeat the process of clicking and typing a few times does the problem shows ?
Yes, now I get the problem. Sorry, there must be something wrong in TWBrowse class. :-(

EMG

Re: WBrowse changes the current file record by itself

Posted: Thu Feb 02, 2012 11:00 am
by Enrico Maria Giordano
Please remove the ALERTs and replace Refresh() with UpStable().

EMG

Re: WBrowse changes the current file record by itself

Posted: Thu Feb 02, 2012 11:31 am
by concentra
Enrico Maria Giordano wrote:Please remove the ALERTs and replace Refresh() with UpStable().
Ok, in this way it works as expected.
But why it do not with the alerts ?
And I tried UpStable() in my application, the one i got the problem, and it didn't work, in fact the problem was greater with it !

Re: WBrowse changes the current file record by itself

Posted: Thu Feb 02, 2012 12:34 pm
by Enrico Maria Giordano
concentra wrote:Ok, in this way it works as expected.
Great! :-)
concentra wrote:But why it do not with the alerts ?
Probably because the alerts cause lostfocus and gotfocus events.

EMG

Re: WBrowse changes the current file record by itself

Posted: Fri Feb 03, 2012 10:37 am
by concentra
Enrico Maria Giordano wrote:Great! :-)
Not so greate since it do not work all the time !
The alerts are there to prove.

Is wbrowse deprecated to xbrowse ? Should I remove it from my apps ?

Re: WBrowse changes the current file record by itself

Posted: Fri Feb 03, 2012 10:42 am
by Antonio Linares
wbrowse is supported and if it is enough for your needs then you can keep using it :-)

xbrowse is the way to go when you need much more features from the browse, that wbrowse does not offer

Re: WBrowse changes the current file record by itself

Posted: Fri Feb 03, 2012 11:19 am
by concentra
Ok Antonio.

And what about this bug ?
Wbrowse changing the file record by itself is a huge issue to me...

[[]] Maurício Faria

Re: WBrowse changes the current file record by itself

Posted: Fri Feb 03, 2012 11:44 am
by Antonio Linares
Mauricio,

As Enrico has pointed, the problem comes from changing the focus meanwhile the browse is working.

If you need to check some values, etc. you can use the function LogFile() or change the caption of the window, etc. Use other ways to report info without interfering with the focus :-)