Page 1 of 1

how to disable tree item

Posted: Tue Nov 11, 2008 10:45 am
by acwoo
#include "FiveWin.ch"
#include "WColors.ch"

function Main()

local oDlg, oTree

DEFINE DIALOG oDlg TITLE "TreeView from source"

@ 0.5, 1 TREEVIEW oTree OF oDlg SIZE 80, 60 COLOR 0, GetSysColor( COLOR_WINDOW )

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT AddItems( oTree )

return nil

function AddItems( oTree )

local oItem1, oItem2, oItem3

oItem1 = oTree:Add( "First" )
oItem1:Add( "One" )
oItem1:Add( "Two" )
oItem1:Add( "Three" )
oItem2 = oTree:Add( "Second" )
oItem2:Add( "Hello" )
oItem2:Add( "World" )
oItem3 = oTree:Add( "Third" )
oItem3:Add( "Last" )
oItem3:Add( "item" )

return nil

How do I disable oItem1:Add( "Two" )

Thanks

Posted: Tue Nov 11, 2008 11:53 am
by JC
Try this:

Code: Select all

function AddItems( oTree )

local oItem1, oItem2, oItem3, oSubItem

oItem1 = oTree:Add( "First" )
oItem1:Add( "One" )

oSubitem := oItem1:Add( "Two" )
oSubitem:disable()

oItem1:Add( "Three" )
oItem2 = oTree:Add( "Second" )
oItem2:Add( "Hello" )
oItem2:Add( "World" )
oItem3 = oTree:Add( "Third" )
oItem3:Add( "Last" )
oItem3:Add( "item" )

return nil

how to disable tree item

Posted: Tue Nov 11, 2008 12:10 pm
by acwoo
Thanks for your help

With the change, I get this error message:

Message not found: TTVITEM:DISABLE


Thanks

Posted: Tue Nov 11, 2008 12:26 pm
by JC
It's possible to make the treeview disabled.
I think maybe not's possible to do the same thing with a item of treeview.

Posted: Tue Nov 11, 2008 12:27 pm
by JC
Acwoo,

Please, try this:

Code: Select all

enableWindow( oItem:hItem, lEnable )

how to disable tree item

Posted: Tue Nov 11, 2008 1:00 pm
by acwoo
Thanks

enableWindow( oItem:hItem, lEnable )

How do I change this to run

Thanks

Posted: Tue Nov 11, 2008 1:33 pm
by JC
Acwoo,

Something like this:

Code: Select all

function AddItems( oTree )

local oItem1, oItem2, oItem3, oSubItem

oItem1 = oTree:Add( "First" )
oItem1:Add( "One" )

oSubitem := oItem1:Add( "Two" )
enableWindow( oSubItem:hItem, .F. )

oItem1:Add( "Three" )
oItem2 = oTree:Add( "Second" )
oItem2:Add( "Hello" )
oItem2:Add( "World" )
oItem3 = oTree:Add( "Third" )
oItem3:Add( "Last" )
oItem3:Add( "item" )

return nil

how to disable tree item

Posted: Tue Nov 11, 2008 1:49 pm
by acwoo
Thanks

Tree "Two" not disabled.


Thanks

Posted: Tue Nov 11, 2008 1:54 pm
by JC
Ok!

I think that not's possible to do!

Posted: Tue Nov 11, 2008 6:16 pm
by JC
Acwoo,

Antonio or Uwe or James, maybe they can help you!

Posted: Tue Nov 11, 2008 9:20 pm
by Antonio Linares
Acwoo,

You can delete a TreeView item (including its childen items) and later on add it again:

http://msdn.microsoft.com/en-us/library ... S.85).aspx

how to disable tree item

Posted: Wed Nov 12, 2008 6:41 am
by acwoo
Thanks

how do I use this TVM_Deleteitem to run


Thanks

Posted: Wed Nov 12, 2008 7:28 pm
by JC
Acwoo,

As Antonio told you... please, try this:

Code: Select all

SendMessage( oTree:hWnd, TVM_DELETEITEM, 0, oItem:hItem )
You can too make a function to control this operation like this:

Code: Select all

function deleteItem( oTree, oItem )
  
  SendMessage( oTree:hWnd, TVM_DELETEITEM, 0, oItem:hItem )

return
And use in your source code like this:

Code: Select all

function AddItems( oTree )

local oItem1, oItem2, oItem3, oSubItem

oItem1 = oTree:Add( "First" )
oItem1:Add( "One" )

oSubitem := oItem1:Add( "Two" )
deleteItem( oTree, oSubItem )

oItem1:Add( "Three" )
oItem2 = oTree:Add( "Second" )
oItem2:Add( "Hello" )
oItem2:Add( "World" )
oItem3 = oTree:Add( "Third" )
oItem3:Add( "Last" )
oItem3:Add( "item" )

return nil

how to disable tree item

Posted: Thu Nov 13, 2008 1:16 pm
by acwoo
Thanks