FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour SetFocus to element in array
Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
SetFocus to element in array
Posted: Thu Feb 26, 2009 08:53 AM

Hi All

I have a browse (twbrowse ) with an array - I am trying to reset the browse incrementally as I search ,
ascan is returning the element I want but I not sure how to reset the browse focus to that
element.

Cheers

Colin

Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: SetFocus to element in array
Posted: Thu Feb 26, 2009 11:49 AM

Hi,

did you try with oLbx:goto( nAt ) where nAt is the array element position ?

regards

MArcelo

Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
Re: SetFocus to element in array
Posted: Thu Feb 26, 2009 01:45 PM

Thanks Marcelo

But goto is not a method of twbrowse

Cheers

Colin

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: SetFocus to element in array
Posted: Thu Feb 26, 2009 02:04 PM

Colin,

Have you tried just setting oLbx:nAt to the value you want, then doing a refresh?

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: SetFocus to element in array
Posted: Thu Feb 26, 2009 02:06 PM

Colin,

Suppose that nNr = the number of the selected element in the array, isn't this example working ?

oLbx:nAt := nNr
oLbx:Refresh()

Good luck.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: SetFocus to element in array
Posted: Thu Feb 26, 2009 02:06 PM

Otto,

You were just a fraction of a second quicker than I was, but with the same suggestion.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
Re: SetFocus to element in array
Posted: Thu Feb 26, 2009 10:48 PM

Thanks All but still not working

@ 12,375 GET oValue1 VAR cValue1 picture '@' UPDATE of oBar SIZE 200,20 ;
on change(if(oValue1:nLastKey>32,chr(oValue1:nLastKey),""),nFnd := ascan(aData,trim(oValue1:cText)),;
if(oValue1:nLastkey==13,(oValue1:Hide(),oValue1:oJump(oLbx),oLbx:SetFocus(),oLbx:GoToCol(1)),(oLbx:nAt := nFnd,oLbx:Refresh()))) ;
FONT oFont ;
PIXEL

I have checked that the ascan is giving me the right item number - nFnd

Any other thoughts

Colin

Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: SetFocus to element in array
Posted: Fri Feb 27, 2009 12:40 AM

Colin,

I had some problems with arrays and tsBrowse ( derivative of twBrowse ). My problems had to do with adding an element to the array, and not being able to see it on the browse.

The bottom line is that I had to do a re-load of the array to the browse and then reposition to the proper element. At that point I could get it into focus.

You may have to experiment a bit to see how the array is being maintained in the browse.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: SetFocus to element in array
Posted: Fri Feb 27, 2009 01:58 AM

Colin,

>Any other thoughts

I think your code is too complex to just test if setting nAt will work. It could be something else in your code that is causing the problem.

I suggest creating a VERY simple example that just displays the browse, then with the press of a button resets nAt and does a refresh. If that doesn't work then post your sample code and maybe we can solve it.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: SetFocus to element in array
Posted: Fri Feb 27, 2009 02:13 AM

Colin,

Here is another thought. You are using oLbx:goToCol( 1 ) in your code. I see no method by that name in TWBrowse nor in TControl or TWindow (the parent classes). Are you perhaps using a different browse or a modified version of TWBrowse?

I just did a search of all the FWH source code and the only PRG containing "gotocol" is TEDITOR.PRG so either your code has an error or you are using a modified browse class.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
Re: SetFocus to element in array
Posted: Fri Feb 27, 2009 02:29 AM

Hi James

I am using Hernan's twbrowse.

Cheers

Colin

Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: SetFocus to element in array
Posted: Fri Feb 27, 2009 11:50 AM
Colin Haig wrote:Thanks Marcelo

But goto is not a method of twbrowse

Cheers

Colin


Colin you are right, was my mistake sorry,

but the other sugestions should work

oLbx:nAt := ArrayPosition
oLbx:refresh()

I tested with Hernan's browse and this work

regards

Marcelo
Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
Re: SetFocus to element in array
Posted: Sat Feb 28, 2009 12:33 AM

Hi Marceo

I have tried

// This works
DEFINE BUTTON oBtn5 of oBar RESOURCE "FIND" ;
FLAT ;
PROMPT 'Find' ;
ACTION(oLbx:skip(20),oLbx:Refresh()) ;
TOOLTIP('Find Value')

// This Does Not Work
DEFINE BUTTON oBtn5 of oBar RESOURCE "FIND" ;
FLAT ;
PROMPT 'Find' ;
ACTION(oLbx:nAt := 20,oLbx:Refresh()) ;
TOOLTIP('Find Value')

Regards

Colin

Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
Re: SetFocus to element in array
Posted: Sat Feb 28, 2009 03:12 AM

To All

This Works
@ 12,375 GET oValue1 VAR cValue1 picture '@' UPDATE of oBar SIZE 200,20 ;
on change(if(oValue1:nLastKey>32,chr(oValue1:nLastKey),""),nItem := ascan(aData,trim(oValue1:cText)),;
if(oValue1:nLastkey==13,(oValue1:Hide(),oValue1:oJump(oLbx),oLbx:SetFocus(),oLbx:GoToCol(1)),(aData[nItem],oLbx:Refresh()))) ;
FONT oFont ;
PIXEL

When I use oLbx:nAt := nValue then tested with MsgInfo(oLbx:nAt) it showed nValue but the
browse would not refresh to the new value.

Regards

Colin

Continue the discussion