(sorry my english)
this a little contribution
we have encountered the difficulty of not being able to use empty arrays with xbrowse
By having an empty array there is no possibility of "create" browse properly, because the indices that serve as an indicator of columns do not exist.
Start
this link is EXE, if you want to try first before making any changes ...
http://www.sitasoft.com/fivewin/test/testarra.rar
we can not build the browser with an empty array, then .... certainly there to initialize an array, but we must keep hidden that row as we want the idea is to create a data that allows us to visualize whether or not that line (s) (init array)
METHOD TO CHANGE...
Pain() (TXBrowse)
KeyDown() (TXBrowse)
KeyChar() (TXBrowse)
GoDown() (TXBrowse)
LButtonDown() (TXBrowse)
RButtonDown() (TXBrowse)
Select() (TXBrowse)
PainData() (TXBrwColumn)
FIND
Code: Select all | Expand
DATA lHeader,; // Browse has header, if this value is nil then is initialized automatically on the Adjust method
ADD BEFORE
Code: Select all | Expand
DATA lEmptyArray AS LOGICAL INIT .F.
FIND INTO METHOD PAINT
Code: Select all | Expand
/*
Paint cols data
*/
ADD AFTER
Code: Select all | Expand
if ::lEmptyArray .and. ::nDataType == DATATYPE_ARRAY
::DispEnd( aInfo )
return 0
endif
FIND INTO METHOD KEYDOWN
Code: Select all | Expand
case nKey == VK_UP
ADD AFTER
Code: Select all | Expand
if ::lEmptyArray .and. ::nDataType == DATATYPE_ARRAY
return 0
endif
FIND INTO METHOD KEYDOWN
Code: Select all | Expand
case nKey == VK_LEFT
ADD AFTER
Code: Select all | Expand
if ::lEmptyArray .and. ::nDataType == DATATYPE_ARRAY
return 0
endif
FIND INTO METHOD KEYDOWN
Code: Select all | Expand
case nKey == VK_RIGHT
ADD AFTER
Code: Select all | Expand
if ::lEmptyArray .and. ::nDataType == DATATYPE_ARRAY
return 0
endif
FIND INTO METHOD KEYCHAR
Code: Select all | Expand
otherwise
ADD AFTER
Code: Select all | Expand
if ::lEmptyArray .and. ::nDataType == DATATYPE_ARRAY
return 0
endif
FIND INTO METHOD GODOWN
Code: Select all | Expand
if ::nLen == 0 .or. ::Eof()
INLINE ADD (END OF LINE)
Code: Select all | Expand
.or. ( ::lEmptyArray .and. ::nDataType == DATATYPE_ARRAY )
FIND INTO METHOD LBUTTONDOWN
Code: Select all | Expand
local nOldCol := ::nColSel
ADD AFTER
Code: Select all | Expand
if ::lEmptyArray .and. ::nDataType == DATATYPE_ARRAY
return 0
endif
FIND INTO METHOD RBUTTONDOWN
Code: Select all | Expand
local nOldCol := ::nColSel
ADD AFTER
Code: Select all | Expand
if ::lEmptyArray .and. ::nDataType == DATATYPE_ARRAY
return 0
endif
FIND INTO METHOD SELECT
Code: Select all | Expand
if ::nMarqueeStyle != MARQSTYLE_HIGHLROWMS
INLINE ADD (END OF LINE)
Code: Select all | Expand
.or. ( ::lEmptyArray .and. ::nDataType == DATATYPE_ARRAY )
FIND INTO METHOD PAINDATA
Code: Select all | Expand
if ! Empty( cData )
ADD BEFORE
Code: Select all | Expand
if ::oBrw:lEmptyArray .and. ::oBrw:nDataType == DATATYPE_ARRAY
return nil
endif
SAMPLE...
Code: Select all | Expand
#include "fivewin.ch"
#include "xbrowse.ch"
function TestMain()
local oWnd
local oBrw
local oBar
local lEmpty := .f.
local aArray := {}
DEFINE WINDOW oWnd TITLE "Testing Empty Array xBrowse"
DEFINE buttonbar oBar of oWnd
define button of oBar action ( oBrw:lEmptyArray := .f., oBrw:Refresh() )
define button of oBar action ( oBrw:lEmptyArray := .t., oBrw:Refresh() )
define button of oBar action ( oWnd:end() )
if empty( aArray )
aArray := {{" "," "," "," "}}
lEmpty := .t.
endif
@ 0,0 XBROWSE oBrw OF oWnd ;
COLUMNS {1,2,3,4} ;
HEADERS {"uno","dos","tres","cuatro"} ;
array aArray LINES CELL fastedit
oBrw:lEmptyArray := lEmpty
oBrw:bPastEof := {|| if ( oBrw:lEmptyArray, ;
oBrw:lEmptyArray:= .f., ;
( aadd( oBrw:aArrayData,{" "," "," "," "} ), oBrw:GoDown()) ),;
oBrw:Refresh() }
oBrw:bKeyDown := {| nKey | EraseRow( oBrw, nKey ) }
aeval( oBrw:aCols, { |oCols| oCols:nEditType := EDIT_GET } )
oWnd:oClient := oBrw
oBrw:createfromcode()
activate window oWnd
return nil
procedure EraseRow( oBrw, nKey )
if nKey == VK_DELETE .and. !oBrw:lEmptyArray
#ifdef __XHARBOUR__
aDel( oBrw:aArraydata, oBrw:nArrayAt,.t. )
#else
aDel( oBrw:aArraydata, oBrw:nArrayAt )
ASize( oBrw:aArraydata, len( oBrw:aArraydata ) - 1 )
#endif
if empty( oBrw:aArraydata )
oBrw:aArraydata := {{" "," "," "," "}}
oBrw:lEmptyArray := .t.
endif
endif
oBrw:refresh()
return