Jump to content
Sign in to follow this  
fisofo

[SOLVED] Disabling Parent TreeView Checkboxes

Recommended Posts

fisofo

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
fisofo

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!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.