Hi all,
I made some changes to the xbrwdisk.prg sample (fwh\samples) in order to navigate folders through two separate xBrowse.
My problem is that selecting folders using the mouse dblclick any xbrowse interfere with the other,
instead using the return key to select folders all xbrowser runs well.
Perhaps there is a bug in the ldblclick method or I should use a different code.
Any ideas ? Thanks in advance.
** This is the self contained sample **
#include "FiveWin.ch"
#include "xbrowse.ch"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oBrw, oBrw1, oTree, oTree1, oFont, b
SET DATE ITALIAN
SET CENTURY ON
oTree := MakeTree()
oTree1 := MakeTree()
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE DIALOG oDlg SIZE 640,440 PIXEL ;
TITLE 'Directory' ;
FONT oFont
@ 10,10 XBROWSE oBrw SIZE 300,70 PIXEL OF oDlg NOBORDER
oBrw:SetTree( oTree, { "\fwh\bitmaps\open2.bmp", ;
"\fwh\bitmaps\16x16\folder.bmp", ;
"\fwh\bitmaps\16x16\onepage2.bmp" } )
oBrw:bKeyChar := { |nKey| If( nKey == VK_RETURN .and. ! Empty( oBrw:oTreeItem:bAction ), ;
Eval( oBrw:oTreeItem:bAction, oBrw:oTreeItem ), nil ) }
WITH OBJECT oBrw:aCols[ 1 ]
:AddBmpFile( "\fwh\bitmaps\hdrive.bmp" )
:nWidth := 300
:cHeader := 'File/Folder'
b := :bLDClickData
:bLDClickData := { |r,c,f,o| ToggleFolder( r,c,f,o,b ) }
:bBmpData := { || If( ':' $ oBrw:oTreeItem:cPrompt, 4, ;
If( 'D' $ oBrw:oTreeItem:Cargo[ 5 ], ;
If( oBrw:oTreeItem:lOpened, 1, 2 ), 3 ) ) }
END
ADD TO XBROWSE oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] ;
PICTURE '@EZ 999,999,999' HEADER 'Bytes'
ADD TO XBROWSE oBrw DATA oBrw:oTreeItem:Cargo[ 3 ] HEADER 'Date'
ADD TO XBROWSE oBrw DATA oBrw:oTreeItem:Cargo[ 4 ] HEADER 'Time'
ADD TO XBROWSE oBrw DATA oBrw:oTreeItem:Cargo[ 5 ] HEADER 'Attr'
oBrw:CreateFromCode()
@ 90,10 XBROWSE oBrw1 SIZE 300,70 PIXEL OF oDlg NOBORDER
oBrw1:SetTree( oTree1, { "\fwh\bitmaps\open2.bmp", ;
"\fwh\bitmaps\16x16\folder.bmp", ;
"\fwh\bitmaps\16x16\onepage2.bmp" } )
oBrw1:bKeyChar := { |nKey| If( nKey == VK_RETURN .and. ! Empty( oBrw1:oTreeItem:bAction ), ;
Eval( oBrw1:oTreeItem:bAction, oBrw1:oTreeItem ), nil ) }
WITH OBJECT oBrw1:aCols[ 1 ]
:AddBmpFile( "\fwh\bitmaps\hdrive.bmp" )
:nWidth := 300
:cHeader := 'File/Folder'
b := :bLDClickData
:bLDClickData := { |r,c,f,o| ToggleFolder( r,c,f,o,b ) }
:bBmpData := { || If( ':' $ oBrw1:oTreeItem:cPrompt, 4, ;
If( 'D' $ oBrw1:oTreeItem:Cargo[ 5 ], ;
If( oBrw1:oTreeItem:lOpened, 1, 2 ), 3 ) ) }
END
ADD TO XBROWSE oBrw1 DATA oBrw1:oTreeItem:Cargo[ 2 ] ;
PICTURE '@EZ 999,999,999' HEADER 'Bytes'
ADD TO XBROWSE oBrw1 DATA oBrw1:oTreeItem:Cargo[ 3 ] HEADER 'Date'
ADD TO XBROWSE oBrw1 DATA oBrw1:oTreeItem:Cargo[ 4 ] HEADER 'Time'
ADD TO XBROWSE oBrw1 DATA oBrw1:oTreeItem:Cargo[ 5 ] HEADER 'Attr'
oBrw1:CreateFromCode()
ACTIVATE DIALOG oDlg CENTER
return nil
//----------------------------------------------------------------------------//
static function ToggleFolder( r, c, f, oCol, b )
local oBrw := oCol:oBrw
local oItem := oBrw:oTreeItem
If ! oItem:lOpened .and. ! Empty( oItem:bAction )
Eval( oItem:bAction, oItem )
endif
if b != nil
Eval( b, r, c, f, oCol )
endif
return nil
//----------------------------------------------------------------------------//
static function MakeTree()
local oTree, oItem, n
local aDrives := aDrives( 2 ) // Hard disks
TREE oTree
for n := 1 to Len( aDrives )
TREEITEM oItem PROMPT aDrives[ n ]
oItem:Cargo := { aDrives[ n ], 0, CtoD( '' ), Space( 8 ), 'D', ;
aDrives[ n ] }
oItem:bAction := { |o| o:SetTree( SubTree( o ) ), o:bACtion := nil }
next
ENDTREE
return oTree
//----------------------------------------------------------------------------//
static function SubTree( oParent )
local oTree, n, oItem, nLevel, nItems := 0
local cFolder := oParent:Cargo[ 6 ]
local aDir := Directory( cFolder + '\*.*', 'D' )
nLevel := oParent:nLevel + 1
TREE oTree
for n := 1 to Len( aDir )
if ! ( aDir[ n ][ 1 ] = '.' )
TREEITEM oItem PROMPT aDir[ n ][ 1 ]
oItem:nlevel := nLevel
oItem:Cargo := aDir[ n ]
AAdd( oItem:Cargo, cFolder + Chr(92) + aDir[ n ][ 1 ] )
if 'D' $ aDir[ n ][ 5 ]
oItem:bAction := { |o| o:SetTree( SubTree( o ) ), o:bACtion := nil }
else
oItem:bAction := { |o| MsgInfo( o:cPrompt ) }
endif
nItems++
endif
next
if nItems == 0
n--
TREEITEM oItem PROMPT ''
oItem:nlevel := nLevel
aDir[ n ][ 5 ] := 'A'
oItem:Cargo := { '', 0, CToD( '' ), Space(8), ' ', '' }
AAdd( oItem:Cargo, cFolder + Chr(92) + aDir[ n ][ 1 ] )
endif
ENDTREE
return oTree
//----------------------------------------------------------------------------//