Sign in to follow this  
Followers 0
Sunblood

Un-bolding a treeview item

7 posts in this topic

Right now the helpfile lists the following remarks under _GuiCtrlTreeViewSetState():

$TVIS_SELECTED 2

$TVIS_CUT 4

$TVIS_DROPHILITED 8

$TVIS_BOLD 16

$TVIS_EXPANDED 32

$TVIS_EXPANDEDONCE 64

$TVIS_EXPANDPARTIAL 128

I want to bold certain items, but they may change later and need to be un-bolded.


Share this post


Link to post
Share on other sites



0 doesn't change anything, as specified in the help file.

BitNOT wouldn't do anything to change it BACK from being bolded already.


Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'll have to look at a way of using the current function in the UDFs, but here's a quick work around

#include <GUIConstants.au3>
#include <GuiTreeView.au3>

Opt("MustDeclareVars", 1)

Dim $h_GUI, $Msg, $treeview, $h_search, $s_file, $h_item

$h_GUI = GUICreate("TreeView UDF Sample", 220, 220)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 200, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "shell32.dll", 3, 4)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)

GUISetState()

$h_search = FileFindFirstFile("C:\*.*")
If $h_search <> -1 Then
    While 1
        $s_file = FileFindNextFile($h_search)
        If @Error Then ExitLoop
        If Not StringInStr(FileGetAttrib("C:\" & $s_file), "D") Then ContinueLoop
        $h_item = _GUICtrlTreeViewInsertItem($treeview, $s_file)
        _GUICtrlTreeViewSetState($treeview, $h_item, $TVIS_BOLD)
        If StringInStr(FileGetAttrib("C:\" & $s_file), "H") Then
;~          _GUICtrlTreeViewSetState($treeview, $h_item, $TVIS_CUT)
            _GUICtrlTreeViewSetStateTest($treeview, $h_item, $TVIS_CUT, $TVIS_BOLD)
        EndIf
    WEnd
EndIf

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Exit

Func _GUICtrlTreeViewSetStateTest($i_treeview, $h_item = 0, $i_state = 0, $i_notState = 0)
    $h_item = _TreeViewGetItemHandle ($i_treeview, $h_item)
    If $h_item = 0 Or $i_state = 0 Then Return 0

    Local $st_TVITEM = DllStructCreate($s_TVITEMEX)
    If @error Then Return SetError(1, 1, 0)

    DllStructSetData($st_TVITEM, 1, $TVIF_STATE)
    DllStructSetData($st_TVITEM, 2, $h_item)
    DllStructSetData($st_TVITEM, 3, $i_state)
    If $i_notState Then
        DllStructSetData($st_TVITEM, 4, BitOR($i_notState, $i_state))
    Else
        DllStructSetData($st_TVITEM, 4, $i_state)
    EndIf

    Return GUICtrlSendMsg($i_treeview, $TVM_SETITEM, 0, DllStructGetPtr($st_TVITEM))
EndFunc   ;==>_GUICtrlTreeViewSetStateTest
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Works great, thanks gafrost.


Share this post


Link to post
Share on other sites

This looks like it will be the replacement

With this one you can set a set only

or

remove a state

or

set a state and remove a state

Func _GUICtrlTreeViewSetState($i_treeview, $h_item, $i_state = 0, $i_stateRemove = 0)
    $h_item = _TreeViewGetItemHandle($i_treeview, $h_item)
    If $h_item = 0 Or ($i_state = 0 And $i_stateRemove = 0) Then Return 0
    
    Local $st_TVITEM    = DllStructCreate($s_TVITEMEX)
    If @error Then Return SetError(1, 1, 0)
    DllStructSetData($st_TVITEM, 1, $TVIF_STATE)
    DllStructSetData($st_TVITEM, 2, $h_item)
    DllStructSetData($st_TVITEM, 3, $i_state)
    DllStructSetData($st_TVITEM, 4, $i_state)
    If $i_stateRemove Then DllStructSetData($st_TVITEM, 4, BitOR($i_stateRemove,$i_state))
    Return GUICtrlSendMsg($i_treeview, $TVM_SETITEM, 0, DllStructGetPtr($st_TVITEM))
EndFunc   ;==>_GUICtrlTreeViewSetState

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0