FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Converting to txBrowse
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Converting to txBrowse
Posted: Thu Jan 15, 2009 11:00 AM

Hi,

I havent used txBrowse yet and i'm looking at converting my old twbrowse routines to txbrowse and was looking for advice.

  1. In my current app, i give the users the ability to pick what fields they want to appear and store this info in a database (column number, contents of column, header text, width of column) Currently i just create a string containing the columns and then after the redefine i populate the oBrw:aHeaders and oBrw:aColSizes arrays. Can someone advise me how to do this using txBrowse?

  2. All my browses use a resource dialog, which i then resize the width based on the total column sizes of all the columns in the browse - how can i get the total width of all columns in a txBrowse as i don't think there is an aColsizes array.

Thanks in advance

Pete

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Converting to txBrowse
Posted: Thu Jan 15, 2009 02:17 PM

>>
1. In my current app, i give the users the ability to pick what fields they want to appear and store this info in a database (column number, contents of column, header text, width of column) Currently i just create a string containing the columns and then after the redefine i populate the oBrw:aHeaders and oBrw:aColSizes arrays. Can someone advise me how to do this using txBrowse?
>>
for n := 1 to nCols
oCol := oBrw:AddCol()
oCol:cHeader := <your header>
oCol:bStrData := <your compiled codeblock>
oCol:nWidth :- <your column size>
next

Because you do this for many browses, you can write one standard function to do this job for you.

>>
2. All my browses use a resource dialog, which i then resize the width based on the total column sizes of all the columns in the browse - how can i get the total width of all columns in a txBrowse as i don't think there is an aColsizes array.
>>

Please study the logic in static function FitSizes( oBrw ) in the source code of xbrowse.prg, You may adopt this logic to suit your needs. You will be able to make a generic function for your needs.

Regards



G. N. Rao.

Hyderabad, India
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Converting to txBrowse
Posted: Thu Jan 15, 2009 02:45 PM

Thanks for your response - that all makes sense!!

One other question, if you configure the xbrowse to have multiple selections, what is stored in the oBrw:aSelected array? Record numbers?

Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Re: Converting to txBrowse
Posted: Thu Jan 15, 2009 05:12 PM

If data is from a alias, you can use too the method :setRdd()
This method build your browse automatically, with sizes, headers, codeblocks and much more!

Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Converting to txBrowse
Posted: Mon Jan 19, 2009 03:41 PM
I'm trying to convert my old browses to xbrowse using a database to store the columns that should appear, however i have a problem. For some reason, the browse is using the last column data for all columns - the header and the sizes are ok howerver. Code example:

		DO WHILE POPUP->CODE == Upper(Padr(cPopCode,10)) .AND. ;
			!POPUP->(EOF())							
			cCol := Alltrim(POPUP->COL) 
			oCol := oBrw:AddCol()
			oCol:cHeader  := POPUP->HEAD
			oCol:bStrData := { || &(cCol)}
			oCol:nWidth   := POPUP->SIZE	
			POPUP->(DBSKIP())
		ENDDO


My browse that i'm trying to create has 2 fields and the POPUP database contains the following:

1st Record

CODE=AREACODE
COL=AREACODE->AREA_CODE
SIZE=120
HEAD=Code

2nd Record
CODE=AREACODE
COL=AREACODE->DESCRIPT
SIZE=300
HEAD=Description

So i have a 2 column browse with the correct description, but the description field in both columns. Can anyone help?

Many Thanks

Pete
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Converting to txBrowse
Posted: Mon Jan 19, 2009 03:56 PM

Hello Peter

i dont test that, but try it...

....
oCol:bStrData := GenbStrData( cCol )
....

function GenbStrData( cCol )
return { || &(cCol) }

Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Converting to txBrowse
Posted: Mon Jan 19, 2009 04:01 PM

Works perfectly - thanks!! :)

Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Converting to txBrowse
Posted: Tue Jan 20, 2009 10:18 AM
Next problem i have...

I have enabled incremental searching that works really well, however i want to enable the enter key to close the browse/dialog and return the highlighted record - i have done this with the bKeydown option, but now the results of my incremental search are not being displayed - the incremental search still works though any ideas? code example below:

   	oBrw:oSeek := oSay1					//Set Incremental Search Object
   	oBrw:cSeek := mSay1 				//Set Incremental Search Data
   	oBrw:bSeek := {|c| &cDbf.->(DbSeek( cPreSeek + Upper( c ) )) }   //Set Incremental Search Rules

oBrw:bKeyDown  := {|nKey|iif(nKey == K_ENTER , (pop_select(oDlg,oRetDlg,oBrw),RetCode := cRetCode ) , NIL )}


Thanks in advance

Pete

Continue the discussion