Sign in to follow this  
Followers 0
James

Treeview Icons

18 posts in this topic

Hi all,

I have a problem with treeview. When an item is right clicked a menu is shown - all good, there is a menu item which is called "mark" which should set the selected item with an icon however when you click "mark" all items are given an icon.

#include <GUITreeView.au3>
#include <GUIConstants.au3>
#include <GUIMenu.au3>

Global $Icons = "shell32.dll"; Icon file
Global Enum $idMenuMark = 1000
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

$GUI = GUICreate("Single Treeview Icon", 218, 335)
$hTreeView = _GUICtrlTreeView_Create($GUI, 8, 8, 201, 321, $iStyle)

$N1 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 1")
$N2 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 2")
$N3 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 3")
$N4 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 4")
$N5 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 5")

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

GUISetState(@SW_SHOW)

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
                Case $NM_RCLICK
                    TreeView_RClick()
                Case $TVN_BEGINLABELEDIT
                    Return False
                Case $TVN_ENDLABELEDIT
                    Local $tInfo = DllStructCreate($tagNMTVDISPINFO, $lParam)
                    Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _
                            DllStructGetData($tInfo, "Text"))
                    If StringLen(DllStructGetData($tBuffer, "Text")) Then Return 1
            EndSwitch
    EndSwitch
EndFunc  ;==>WM_NOTIFY

Func TreeView_RClick()
    Local $Hit, $MousePos, $hMenu

    $Hit = _GUICtrlTreeView_GetSelection($hTreeView)
    If ($Hit <> 0) Then
        $hMenu = _GUICtrlMenu_CreatePopup()
        $mHi = _GUICtrlMenu_AddMenuItem($hMenu, "Mark", $idMenuMark)
        If _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then _GUICtrlMenu_SetItemText($hMenu, $mHi, "Unmark")
        Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hTreeView, -1, -1, 1, 1, 2)
            Case $idMenuMark
                If Not _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then
                    _GUICtrlTreeView_SetBold($hTreeView, $Hit)
                    _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, 1)
                Else
                    _GUICtrlTreeView_SetBold($hTreeView, $Hit, False)
                    _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, False)
                EndIf
        EndSwitch
        _GUICtrlMenu_DestroyMenu($hMenu)
    EndIf
EndFunc  ;==>TreeView_RClick

My "snippet" as short as I could get while still keeping the same code I use with my full file. I need to know how to only mark the one (selected) icon and then unmark it when I click unmark on the menu.

Thanks,

James

Share this post


Link to post
Share on other sites



#include <GUITreeView.au3>
#include <GUIConstantsEx.au3>
#include <GUIMenu.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>

Global $Icons = "shell32.dll"; Icon file
Global Enum $idMenuMark = 1000
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

$GUI = GUICreate("Single Treeview Icon", 218, 335)
$hTreeView = _GUICtrlTreeView_Create($GUI, 8, 8, 201, 321, $iStyle)

$hImage = _GUIImageList_Create(16, 16, 5, 3)
;~ _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImage)


$N1 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 1")
$N2 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 2")
$N3 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 3")
$N4 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 4")
$N5 = _GUICtrlTreeView_Add($hTreeView, 0, "Item 5")

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

GUISetState(@SW_SHOW)

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
                Case $NM_RCLICK
                    TreeView_RClick()
                Case $TVN_BEGINLABELEDIT
                    Return False
                Case $TVN_ENDLABELEDIT
                    Local $tInfo = DllStructCreate($tagNMTVDISPINFO, $lParam)
                    Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _
                            DllStructGetData($tInfo, "Text"))
                    If StringLen(DllStructGetData($tBuffer, "Text")) Then Return 1
            EndSwitch
    EndSwitch
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func TreeView_RClick()
    Local $Hit, $MousePos, $hMenu

    $Hit = _GUICtrlTreeView_GetSelection($hTreeView)
    If ($Hit <> 0) Then
        $hMenu = _GUICtrlMenu_CreatePopup()
        $mHi = _GUICtrlMenu_AddMenuItem($hMenu, "Mark", $idMenuMark)
        If _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then _GUICtrlMenu_SetItemText($hMenu, $mHi, "Unmark")
        Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hTreeView, -1, -1, 1, 1, 2)
            Case $idMenuMark
                If Not _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then
                    _GUICtrlTreeView_SetBold($hTreeView, $Hit)
                    _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, 1)
                Else
                    _GUICtrlTreeView_SetBold($hTreeView, $Hit, False)
                    _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, False)
                EndIf
        EndSwitch
        _GUICtrlMenu_DestroyMenu($hMenu)
    EndIf
EndFunc   ;==>TreeView_RClick


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

#4 ·  Posted (edited)

Hi,

this way it works for the subItems but without contextmenu

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
  #include <GuiConstantsEx.au3>
  #include <GuiTreeView.au3>
  #include <WindowsConstants.au3>
  
  Opt('MustDeclareVars', 1)
  
  $Debug_TV = False; Check ClassName being passed to functions, set to True and use a handle to another control to see it work
  
  _Main()
  
  Func _Main()
  
      Local $hItem[10], $hChildItem[30], $iYItem = 0, $hTreeView
      Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
  
      GUICreate("TreeView Set Icon", 400, 300)
  
      $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
      _GUICtrlTreeView_SetUnicodeFormat($hTreeView, False)
      GUISetState()
  
      _GUICtrlTreeView_BeginUpdate($hTreeView)
      For $x = 0 To 9
          $hItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $hTreeView)
          _GUICtrlTreeView_SetIcon($hTreeView, $hItem[$x], "shell32.dll", 3)
          For $y = 1 To 3
              $hChildItem[$iYItem] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $hItem[$x])
              _GUICtrlTreeView_SetIcon($hTreeView, $hChildItem[$iYItem], "shell32.dll", Random(1,10,1))
              $iYItem += 1
          Next
      Next
      _GUICtrlTreeView_EndUpdate($hTreeView)
;~   _GUICtrlTreeView_SetIcon($hTreeView, $hItem[0], "shell32.dll", 4)
  
   ; Loop until user exits
      Do
      Until GUIGetMsg() = $GUI_EVENT_CLOSE
      GUIDelete()
  EndFunc;==>_Main

Edit: Much too late.

Edit 2 : Your code doesn't work Gary. All icons are still set when you click them.

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Thanks Gary however like Xeno pointed out it sets all items when it has been clicked.

Xeno, yours works I just need to know if it would work with a menu?

Hi,

:D somebody needs to explain to me, how to use GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") for creating some action on right click. Afterwards I can try to implement it and test it.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#include <GuiTreeView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>
#include <StructureConstants.au3>
#include <TreeViewConstants.au3>
;~ #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

Opt('MustDeclareVars', 1)

Global $Icons = "shell32.dll"; Icon file
Global Enum $idMenuMark = 1000
Global $hTreeView, $hWnd, $iMsg, $iwParam, $lParam; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

Global $hItem[10], $hChildItem[30], $iYItem = 0
Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

Global $GUI = GUICreate("TreeView Set Icon", 400, 300)

$hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
_GUICtrlTreeView_SetUnicodeFormat($hTreeView, False)
GUISetState()

_GUICtrlTreeView_BeginUpdate($hTreeView)
For $x = 0 To 9
    $hItem[$x] = _GUICtrlTreeView_Add($hTreeView, StringFormat("[%02d] New Item", $x), $hTreeView)
    _GUICtrlTreeView_SetIcon($hTreeView, $hItem[$x], "shell32.dll", 3)
    For $y = 1 To 3
        $hChildItem[$iYItem] = _GUICtrlTreeView_AddChild($hTreeView , $hItem[$x], StringFormat("[%02d] New Child", $y))
        _GUICtrlTreeView_SetIcon($hTreeView, $hChildItem[$iYItem], "shell32.dll", Random(1, 10, 1))
        $iYItem += 1
    Next
Next
_GUICtrlTreeView_EndUpdate($hTreeView)
;~     _GUICtrlTreeView_SetIcon($hTreeView, $hItem[0], "shell32.dll", 4)

; Loop until user exits
Do
    Sleep(50)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()


Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
                Case $NM_RCLICK
                    TreeView_RClick()
                Case $TVN_BEGINLABELEDIT
                    Return False
                Case $TVN_ENDLABELEDIT
                    Local $tInfo = DllStructCreate($tagNMTVDISPINFO, $lParam)
                    Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _
                            DllStructGetData($tInfo, "Text"))
                    If StringLen(DllStructGetData($tBuffer, "Text")) Then Return 1
            EndSwitch
    EndSwitch
EndFunc   ;==>WM_NOTIFY

Func TreeView_RClick()
    ConsoleWrite('TreeView_RClick()' & @CRLF)
    Local $Hit, $MousePos, $hMenu, $mHi

    $Hit = _GUICtrlTreeView_GetSelection($hTreeView)
    ConsoleWrite($Hit & @CRLF)
    If ($Hit <> 0) Then
        $hMenu = _GUICtrlMenu_CreatePopup()
        $mHi = _GUICtrlMenu_AddMenuItem($hMenu, "Mark", $idMenuMark)
        If _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then _GUICtrlMenu_SetItemText($hMenu, $mHi, "Unmark")
        Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hTreeView, -1, -1, 1, 1, 2)
            Case $idMenuMark
                If Not _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then
                    _GUICtrlTreeView_SetBold($hTreeView, $Hit)
                    _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, 1)
                Else
                    _GUICtrlTreeView_SetBold($hTreeView, $Hit, False)
                    _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, False)
                EndIf
        EndSwitch
        _GUICtrlMenu_DestroyMenu($hMenu)
    EndIf
EndFunc   ;==>TreeView_RClick


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

#include <GuiTreeView.au3>
 #include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 #include <GuiMenu.au3>
 #include <StructureConstants.au3>
 #include <TreeViewConstants.au3>
 ;~ #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
 
 Opt('MustDeclareVars', 1)
 
 Global $Icons = "shell32.dll"; Icon file
 Global Enum $idMenuMark = 1000, $idMenuMark1
 Global $hTreeView, $hWnd, $iMsg, $iwParam, $lParam; Check ClassName being passed to functions, set to True and use a handle to another control to see it work
 
 GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
 
 Global $hItem[10], $hChildItem[30], $iYItem = 0
 Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
 
 Global $GUI = GUICreate("TreeView Set Icon", 400, 300)
 
 $hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
 _GUICtrlTreeView_SetUnicodeFormat($hTreeView, False)
 GUISetState()
 
 _GUICtrlTreeView_BeginUpdate($hTreeView)
 For $x = 0 To 9
     $hItem[$x] = _GUICtrlTreeView_Add($hTreeView, StringFormat("[%02d] New Item", $x), $hTreeView)
     _GUICtrlTreeView_SetIcon($hTreeView, $hItem[$x], "shell32.dll", 3)
     For $y = 1 To 3
         $hChildItem[$iYItem] = _GUICtrlTreeView_AddChild($hTreeView, $hItem[$x], StringFormat("[%02d] New Child", $y))
         _GUICtrlTreeView_SetIcon($hTreeView, $hChildItem[$iYItem], "shell32.dll", Random(1, 10, 1))
         $iYItem += 1
     Next
 Next
 _GUICtrlTreeView_EndUpdate($hTreeView)
 ;~     _GUICtrlTreeView_SetIcon($hTreeView, $hItem[0], "shell32.dll", 4)
 
 ; Loop until user exits
 Do
 Until GUIGetMsg() = $GUI_EVENT_CLOSE
 GUIDelete()
 
 Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $lParam)
     Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
     $hWndTreeview = $hTreeView
     If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
 
     $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
     $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
     $iCode = DllStructGetData($tNMHDR, "Code")
 
     Switch $hWndFrom
         Case $hWndTreeview
             Switch $iCode
                 Case $NM_RCLICK
                     TreeView_RClick()
                 Case $TVN_BEGINLABELEDIT
                     Return False
                 Case $TVN_ENDLABELEDIT
                     Local $tInfo = DllStructCreate($tagNMTVDISPINFO, $lParam)
                     Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _
                             DllStructGetData($tInfo, "Text"))
                     If StringLen(DllStructGetData($tBuffer, "Text")) Then Return 1
             EndSwitch
     EndSwitch
 EndFunc  ;==>WM_NOTIFY
 
 Func TreeView_RClick()
     ConsoleWrite('TreeView_RClick()' & @CRLF)
     Local $Hit, $MousePos, $hMenu, $mHi, $rIcon
 
     $Hit = _GUICtrlTreeView_GetSelection($hTreeView)
     ConsoleWrite($Hit & @CRLF)
     If ($Hit <> 0) Then
         $hMenu = _GUICtrlMenu_CreatePopup()
         $mHi = _GUICtrlMenu_AddMenuItem($hMenu, "Mark", $idMenuMark)
         $rIcon = _GUICtrlMenu_AddMenuItem($hMenu, "Remove", $idMenuMark1)
         If _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then _GUICtrlMenu_SetItemText($hMenu, $mHi, "Unmark")
         Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hTreeView, -1, -1, 1, 1, 2)
             Case $idMenuMark
                 If Not _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then
                     _GUICtrlTreeView_SetBold($hTreeView, $Hit)
                     _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, 1)
                 Else
                     _GUICtrlTreeView_SetBold($hTreeView, $Hit, False)
                     _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, False)
                 EndIf
             Case $idMenuMark1
                 _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, -4)
         EndSwitch
         _GUICtrlMenu_DestroyMenu($hMenu)
     EndIf
 EndFunc  ;==>TreeView_RClick

Edit: click left on the treeview item then right mark or remove (set to default)

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hTreeView, -1, -1, 1, 1, 2)
             Case $idMenuMark
                 If Not _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then
                     _GUICtrlTreeView_SetBold($hTreeView, $Hit)
                     _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, 1)
                 Else
                     _GUICtrlTreeView_SetBold($hTreeView, $Hit, False)
                     _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, False)
                 EndIf
             Case $idMenuMark1
                 _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, -4)
         EndSwitchoÝ÷ Ûú®¢×+2¢êÞÅ©©ì(®Kw¢»¶'(Çè®ÚÞ¾'°×¦±8ZK¢»!j¸§­¶«z+)®åzf¢ëkzj/x%vËZµâ-±ç¦²Ú,¢gPh§²Ö§uªÝè­çì»x§r[y«­¢+Ù}U%
ÑɱQÉY¥Ý}MÑ  ½± ÀÌØí¡QÉY¥Ü°ÀÌØí!¥Ð°±Í¤()Õ¹}U%
ÑɱQÉY¥Ý}MÑ  ½± ÀÌØí¡]¹°ÀÌØí¡%Ñ´°ÀÌØí±ôQÉÕ¤(%IÑÕɸ}U%
ÑɱQÉY¥Ý}MÑMÑÑ ÀÌØí¡]¹°ÀÌØí¡%Ñ´°ÀÌØíQY%M}   =1°ÀÌØí±¤)¹Õ¹ìôôÐí}U%
ÑɱQÉY¥Ý}MÑ  ½±()Õ¹}U%
ÑɱQÉY¥Ý}MÑMÑÑ ÀÌØí¡]¹°ÀÌØí¡%Ñ´°ÀÌØí¥MÑÑôÀ°ÀÌØí¥MÑÑIµ½ÙôÀ¤(%%ÀÌØíÕ}QXQ¡¸}U%
ÑɱQÉY¥Ý}Y±¥Ñ
±ÍÍ9µ ÀÌØí¡]¹¤(%%9½Ð%Í!]¹ ÀÌØí¡%Ñ´¤Q¡¸ÀÌØí¡%Ñ´ô}U%
ÑɱQÉY¥Ý}Ñ%ѵ!¹± ÀÌØí¡]¹°ÀÌØí¡%Ñ´¤(%%ÀÌØí¡%Ñ´ôÀ=È ÀÌØí¥MÑÑôÀ¹ÀÌØí¥MÑÑIµ½ÙôÀ¤Q¡¸IÑÕɸ±Í($%1½°ÀÌØíÑQY%Q4ô±±MÑÉÕÑ
ÉÑ ÀÌØíÑQY%Q5`¤(%%ÉɽÈQ¡¸IÑÕɸMÑÉÉ½È Ä°Ä°À¤(%±±MÑÉÕÑMÑÑ ÀÌØíÑQY%Q4°ÅÕ½Ðí5ͬÅÕ½Ðì°ÀÌØíQY%}MQQ¤(%±±MÑÉÕÑMÑÑ ÀÌØíÑQY%Q4°ÅÕ½Ðí¡%Ñ´ÅÕ½Ðì°ÀÌØí¡%Ñ´¤(%±±MÑÉÕÑMÑÑ ÀÌØíÑQY%Q4°ÅÕ½ÐíMÑÑÅÕ½Ðì°ÀÌØí¥MÑѤ(%±±MÑÉÕÑMÑÑ ÀÌØíÑQY%Q4°ÅÕ½ÐíMÑÑ5ͬÅÕ½Ðì°ÀÌØí¥MÑѤ(%%ÀÌØí¥MÑÑIµ½ÙQ¡¸±±MÑÉÕÑMÑÑ ÀÌØíÑQY%Q4°ÅÕ½ÐíMÑÑ5ͬÅÕ½Ðì°   ¥Ñ=H ÀÌØí¥MÑÑIµ½Ù°ÀÌØí¥MÑѤ¤(%%9½Ð%Í!]¹ ÀÌØí¡]¹¤Q¡¸ÀÌØí¡]¹ôU%
ÑɱÑ!¹± ÀÌØí¡]¹¤(%IÑÕɸ}U%
ÑɱQÉY¥Ý}MÑ%Ñ´ ÀÌØí¡]¹°ÀÌØíÑQY%Q4¤)¹Õ¹ìôôÐí}U%
ÑɱQÉY¥Ý}MÑMÑÑ

Share this post


Link to post
Share on other sites

Hi,

do not understand your words.

This shows how to remove bold too

#include <GuiTreeView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>
#include <StructureConstants.au3>
#include <TreeViewConstants.au3>
;~ #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

Opt('MustDeclareVars', 1)

Global $Icons = "shell32.dll"; Icon file
Global Enum $idMenuMark = 1000, $idMenuMark1
Global $hTreeView, $hWnd, $iMsg, $iwParam, $lParam; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

Global $hItem[10], $hChildItem[30], $iYItem = 0
Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

Global $GUI = GUICreate("TreeView Set Icon", 400, 300)

$hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
_GUICtrlTreeView_SetUnicodeFormat($hTreeView, False)
GUISetState()

_GUICtrlTreeView_BeginUpdate($hTreeView)
For $x = 0 To 9
    $hItem[$x] = _GUICtrlTreeView_Add($hTreeView, StringFormat("[%02d] New Item", $x), $hTreeView)
    _GUICtrlTreeView_SetIcon($hTreeView, $hItem[$x], "shell32.dll", 3)
    For $y = 1 To 3
        $hChildItem[$iYItem] = _GUICtrlTreeView_AddChild($hTreeView, $hItem[$x], StringFormat("[%02d] New Child", $y))
        _GUICtrlTreeView_SetIcon($hTreeView, $hChildItem[$iYItem], "shell32.dll", Random(1, 10, 1))
        $iYItem += 1
    Next
Next
_GUICtrlTreeView_EndUpdate($hTreeView)
;~     _GUICtrlTreeView_SetIcon($hTreeView, $hItem[0], "shell32.dll", 4)

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
                Case $NM_RCLICK
                    TreeView_RClick()
                Case $TVN_BEGINLABELEDIT
                    Return False
                Case $TVN_ENDLABELEDIT
                    Local $tInfo = DllStructCreate($tagNMTVDISPINFO, $lParam)
                    Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _
                            DllStructGetData($tInfo, "Text"))
                    If StringLen(DllStructGetData($tBuffer, "Text")) Then Return 1
            EndSwitch
    EndSwitch
EndFunc   ;==>WM_NOTIFY

Func TreeView_RClick()
    ConsoleWrite('TreeView_RClick()' & @CRLF)
    Local $Hit, $MousePos, $hMenu, $mHi, $rIcon

    $Hit = _GUICtrlTreeView_GetSelection($hTreeView)
    ConsoleWrite($Hit & @CRLF)
    If ($Hit <> 0) Then
        $hMenu = _GUICtrlMenu_CreatePopup()
        $mHi = _GUICtrlMenu_AddMenuItem($hMenu, "Mark", $idMenuMark)
        $rIcon = _GUICtrlMenu_AddMenuItem($hMenu, "Remove", $idMenuMark1)
        If _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then _GUICtrlMenu_SetItemText($hMenu, $mHi, "Unmark")
        Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hTreeView, -1, -1, 1, 1, 2)
            Case $idMenuMark
                If Not _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then
                    _GUICtrlTreeView_SetBold($hTreeView, $Hit)
                    _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, 1)
                Else
                    _GUICtrlTreeView_SetBold($hTreeView, $Hit, False)
                    _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, False)
                EndIf
            Case $idMenuMark1
                If _GUICtrlTreeView_GetBold($hTreeView, $Hit) Then _GUICtrlTreeView_SetBold($hTreeView, $Hit, False)
                _GUICtrlTreeView_SetIcon($hTreeView, $Hit, $Icons, -4)
        EndSwitch
        _GUICtrlMenu_DestroyMenu($hMenu)
    EndIf
EndFunc   ;==>TreeView_RClick

Besides: Zedna you should become the second man to watch for all the UDFs!!!

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

do not understand your words.

This shows how to remove bold too

I know how it should work but on my WINXP SP2 CZ it doesn't remove Bold state when I select unmark, it only removes icon.

Besides: Zedna you should become the second man to watch for all the UDFs!!!

I didn't get the point. What do you mean by this exactly?

I think I'm skilled enough in browsing standard include UDFs.

Share this post


Link to post
Share on other sites

I know how it should work but on my WINXP SP2 CZ it doesn't remove Bold state when I select unmark, it only removes icon.

I didn't get the point. What do you mean by this exactly?

I think I'm skilled enough in browsing standard include UDFs.

1) Weird. It works for me in both cases. Clicking unmark or remove --> bold state is gone. [Latest beta]

2) I meant, you should assist Gary with checking all the includes and improve them. Like Siao pointed out here : #511169

Gary is very good, but I guess checking all the includes for speed improvements or just usability is very very much to do!

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

1) Weird. It works for me in both cases. Clicking unmark or remove --> bold state is gone. [Latest beta]

Yes!

It's reason

I tested it on release 3.2.10

Now I tested it on latest beta and it's OK.

I use release 3.2.10 as default and latest beta only when it's needed.

So conlusion: Here it's needed to use latest beta :-)

EDIT: There is correction in beta UDF _GUICtrlTreeView_SetState() for that

Edited by Zedna

Share this post


Link to post
Share on other sites

Yes!

It's reason

I tested it on release 3.2.10

Now I tested it on latest beta and it's OK.

I use release 3.2.10 as default and latest beta only when it's needed.

So conlusion: Here it's needed to use latest beta :-)

EDIT: There is correction in beta UDF _GUICtrlTreeView_SetState() for that

Ah okay, so it is fine.

I always use latest beta. :D

You didn't comment my suggestion. Any reason?

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

2) I meant, you should assist Gary with checking all the includes and improve them. Like Siao pointed out here : #511169

Gary is very good, but I guess checking all the includes for speed improvements or just usability is very very much to do!

I assist only little due to lack of my free time.

You are right. It's HUGE project (all UDFs) and Gary is hero in my mind and he is very good in it.

Share this post


Link to post
Share on other sites

I assist only little due to lack of my free time.

You are right. It's HUGE project (all UDFs) and Gary is hero in my mind and he is very good in it.

Hi,

ah okay that's of course a good reason.

No doubt about it, but sometimes it is a sign of strength to ask for help. :D

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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