Jump to content

[SOLVED] Disabling Parent TreeView Checkboxes


fisofo
 Share

Recommended Posts

Summary: I want to disable specific TreeView Item checkboxes (grayed out, disabled, invisible, whatever!) and leave others intact.

I've searched and found Holger's Tristate GUI TreeView as well as a more specific post from him about what I am trying to do, however after updating the code to work with the most recent AutoIt versions, I find it is not working for me. The code in that second post is actually just a simplified version of his Tristate stuff, so I focused on that (although I tested both), and I produced the below code, which is unfortunately not working. The Struct appears to be correct as far as I can tell from MSDN as well... Any thoughts?

I am running Win7 x64.

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>

Global Const $TVM_SETITEM   = $TV_FIRST + 13

GUICreate('Test')

$tv     = GUICtrlCreateTreeView(10, 10, 200, 200, BitOr($TVS_HASBUTTONS, $TVS_DISABLEDRAGDROP, $TVS_HASLINES, $TVS_HASLINES, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES))
$tvitem1    = GUICtrlCreateTreeViewItem('Item1', $tv)
$tvitem2    = GUICtrlCreateTreeViewItem('Item2', $tvitem1)
$tvitem3    = GUICtrlCreateTreeViewItem('Item3', $tvitem1)

GUICtrlSetState($tvitem1, $GUI_EXPAND)

RemoveCheckbox($tv, $tvitem1)

GUISetState()

While 1
    $Msg = GUIGetMsg()

    Switch $Msg
    Case $GUI_EVENT_CLOSE
    ExitLoop
    EndSwitch
WEnd

Exit

Func RemoveCheckbox($nTV, $nID)
    Local $hItem = GUICtrlGetHandle($nID)
    If $hItem = 0 Then $hItem = $nID

    Local $stTVITEM = DllStructCreate('uint;uint;uint;uint;ptr;int;int;int;int;uint;int')

    DllStructSetData($stTVITEM, 1, $TVIF_STATE)
    DllStructSetData($stTVITEM, 2, $hItem)
    DllStructSetData($stTVITEM, 3, 0)
    DllStructSetData($stTVITEM, 4, $TVIS_STATEIMAGEMASK)

    GUICtrlSendMsg($nTV, $TVM_SETITEM, 0, DllStructGetPtr($stTVITEM))
EndFunc
Edited by fisofo
Link to comment
Share on other sites

Well, it works fine on Vista 32-bit (root item has no checkbox), so it may be 64-bit related issue. If you compile it 32-bit and run it, does it work for you?

;)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well, it works fine on Vista 32-bit (root item has no checkbox), so it may be 64-bit related issue. If you compile it 32-bit and run it, does it work for you?

;)

Doh! That makes sense... thanks Psalty! When I compiled the example, it worked perfectly for me, so I reinstalled the latest AutoIt but chose not to include native x64 components. Should this be submitted as a bug somewhere? I looked around and see that others have had similar issues though, so perhaps the team is aware of it.

In any case, thanks much Psalty!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...