FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour problem with xbrwdisk.prg
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
problem with xbrwdisk.prg
Posted: Wed Feb 17, 2010 12:46 AM
I did some tests with xbrwdisk.prg.
I noticed:
1) ENTER and ESC only work if you first have clicked on that folder.

2) I get an error if I click on an empty folder .

Best regards,
Otto

Application
===========
Path and name: C:\FWH\samples\xbrwdisk.exe (32 bits)
Size: 1,768,960 bytes
Time from start: 0 hours 0 mins 22 secs
Error occurred at: 17-02-10, 01:41:15
Error description: Error BASE/1005 Class: 'NIL' has no property: OPREV
Args:
[ 1] = U
[ 2] = O TTREEITEM

Stack Calls
===========
Called from: => _OPREV(0)
Called from: C:\FWH\samples\xbrwdisk.prg => SETSUBTREE(129)
Called from: C:\FWH\samples\xbrwdisk.prg => (b)SUBTREE(114)
Called from: C:\FWH\samples\xbrwdisk.prg => TOGGLEFOLDER(58)
Called from: C:\FWH\samples\xbrwdisk.prg => (b)MAIN(29)
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:LDBLCLICK(3437)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1469)
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT(10352)
Called from: .\source\classes\WINDOW.PRG => _FWH(3353)
Called from: => DIALOGBOXINDIRECT(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
Called from: C:\FWH\samples\xbrwdisk.prg => MAIN(46)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: problem with xbrwdisk.prg
Posted: Wed Feb 17, 2010 03:20 AM
Please change the static function SetSubTree to check for empty subtree;
Modified code
Code (fw): Select all Collapse
static function SetSubTree( oItem, oTree )

   if oTree:nCount() > 0   // now inserted
      oTree:oFirst:oPrev   := oItem
      oTree:oLast:SetNext( oItem:oNext )
      oItem:oTree := oTree
   endif  // now inserted

return oItem
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: problem with xbrwdisk.prg
Posted: Wed Feb 17, 2010 07:19 AM

Dear Mr. NageswaraRao,
Your changes solved the problem. Now if a folder is empty you don’t get an error anymore.
Thank you very much.
Could you please have a look why ENTER key only works on folders you have once opened first with the mouse, too.

Thanks in advance
Otto

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: problem with xbrwdisk.prg
Posted: Wed Feb 17, 2010 07:26 AM

Dear Mr. NageswaraRao,
do you think it should be possible if directory is empty to insert a pseudo item to get more a windows explorer like feeling.
Best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: problem with xbrwdisk.prg
Posted: Wed Feb 17, 2010 12:19 PM
Otto wrote:Dear Mr. NageswaraRao,
do you think it should be possible if directory is empty to insert a pseudo item to get more a windows explorer like feeling.
Best regards,
Otto

Please use this modified function.
Code (fw): Select all Collapse
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 }
         endif
         nItems++
      endif
   next
   if nItems == 0
      n--
      TREEITEM oItem PROMPT '.'
      oItem:nlevel := nLevel
      aDir[ n ][ 5 ] := 'A'
      oItem:Cargo  := aDir[ n ]
      AAdd( oItem:Cargo, cFolder + Chr(92) + aDir[ n ][ 1 ] )
   endif
   ENDTREE

return oTree
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: problem with xbrwdisk.prg
Posted: Wed Feb 17, 2010 12:21 PM
Otto wrote:Dear Mr. NageswaraRao,
Your changes solved the problem. Now if a folder is empty you don’t get an error anymore.
Thank you very much.
Could you please have a look why ENTER key only works on folders you have once opened first with the mouse, too.

Thanks in advance
Otto

Please add this after oBrw:SetTree( ... )
Code (fw): Select all Collapse
   oBrw:bKeyChar  := { |nKey| If( nKey == VK_RETURN .and. ! Empty( oBrw:oTreeItem:bAction ), ;
                                Eval( oBrw:oTreeItem:bAction, oBrw:oTreeItem ), nil ) }
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: problem with xbrwdisk.prg
Posted: Wed Feb 17, 2010 01:23 PM
Dear Mr. NagesWaraRao,

thank you so much. Now all is working as suspected.

May I ask you two more questions?
I would like to use this code to select a certain letter.
I change
local aDrives := aDrives( 2 ) // Hard disks
to
local aDrives := { "c:\xwinhotel"}

This way I see the folder where the letters are.
Now I would like to start with the treeview in open status and then when I click on an item or press ENTER I would like to select an Item: msginfo( “You selected item: “ + ???)
Would you be so kind to help me?
Thanks in advance
Otto
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: problem with xbrwdisk.prg
Posted: Wed Feb 17, 2010 03:54 PM
Otto wrote:Dear Mr. NagesWaraRao,
I would like to use this code to select a certain letter.
I change
local aDrives := aDrives( 2 ) // Hard disks
to
local aDrives := { "c:\xwinhotel"}

This way I see the folder where the letters are.
Now I would like to start with the treeview in open status and then when I click on an item or press ENTER I would like to select an Item: msginfo( “You selected item: “ + ???)
Otto

Please use this replacement for function MakeTree
Code (fw): Select all Collapse
static function MakeTree()

   local oTree, oItem
   local cPath := 'C:\FWH'

   TREE oTree
      TREEITEM oItem PROMPT cPath
      oItem:Cargo    := { cPath, 0, CtoD( '' ), Space( 8 ), 'D', cPath }
      oItem:SetTree( SubTree( oItem ) )
      oItem:Open()
   ENDTREE

return oTree

Also replace this old code in SubTree function
Code (fw): Select all Collapse
         if 'D' $ aDir[ n ][ 5 ]
            oItem:bAction  := { |o| o:SetTree( SubTree( o ) ), o:bACtion := nil }
         endif

with
Code (fw): Select all Collapse
         if 'D' $ aDir[ n ][ 5 ]
            oItem:bAction  := { |o| o:SetTree( SubTree( o ) ), o:bACtion := nil }
         else
            oItem:bAction  := { |o| MsgInfo( o:cPrompt ) }
         endif

I used 'C:\FWH' folder for my testing. You may change it to your folder.
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: problem with xbrwdisk.prg
Posted: Wed Feb 17, 2010 05:36 PM

Dear Mr. NagesWaraRao,
Thank you very much for your help. Now I have all the functionality I need.
Best regards,
Otto

Continue the discussion