Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have made a tree view control in dialog box, using resource editor.

I have set the checkbox style with SetWindowLongPtr( ... ) function, the way Microsoft described.

Every node has checkbox this way, yet I need only some to have checkbox, and some to have nothing standing next to their text ( parent nodes do NOT have checkbox, only child or simple ones->ones without children ).

Can this be achieved by subclassing, or maybe with custom/owner draw or perhaps superclassing ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
339 views
Welcome To Ask or Share your Answers For Others

1 Answer

The tree control uses state images to draw the checkboxes. According to the docs on the TVS_CHECKBOXES style:

State image 1 is the unchecked box and state image 2 is the checked box. Setting the state image to zero removes the check box altogether.

So something like this should let you remove the check box from a tree item:

TVITEM tvi;
tvi.hItem = hTreeItem;
tvi.mask = TVIF_STATE;
tvi.stateMask = TVIS_STATEIMAGEMASK;
tvi.state = 0;
TreeView_SetItem(hWndTree, &tvi);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...