1

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 ?

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Please don't put tag information in your title. The tagging system here is very good at classifying things, and doesn't need help. :-) Please see [Should questions include "tags" in their titles?](http://meta.stackexchange.com/q/19190/172661). Thanks. Also, please stop beginning every post with a thanks in advance for helping. It's not necessary here. :-) – Ken White Jul 22 '13 at 22:33
  • I will never do that again, I promise, I am new here, and have typed some questions that way, hoping for question to be complete. I am sorry. –  Jul 22 '13 at 22:40
  • 1
    Nothing to apologize for; my comment was meant to be helpful so you'd know in the future. :-) – Ken White Jul 22 '13 at 22:43

1 Answers1

2

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);
Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79
  • That is what I thought, but what if user clicks on the node? The checkbox is shown then? –  Jul 22 '13 at 22:57
  • Try it and see! You could always sub-class the tree and throw away the clicks if they're on a checkbox that shouldn't be there. – Jonathan Potter Jul 22 '13 at 23:13
  • OK, I will try it. I will post my reply tomorrow. Thank you! –  Jul 22 '13 at 23:49
  • Thank you so much!!! God bless you! To bad I can't upvote it :((( So simple and so effective! –  Jul 23 '13 at 14:46
  • I have just got 15 rep points, so I gave you +1. Thank you again for your help. Can you help me with this problem, by any chance? It is really important to me, please: http://stackoverflow.com/questions/17888038/transparent-tree-view-control Thank you. –  Jul 26 '13 at 19:59