删除并向树控件中的节点添加复选框 [英] Removing and adding checkboxes to the nodes in a treecontrol

查看:126
本文介绍了删除并向树控件中的节点添加复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我用win32创建了一个树控件。现在我想随机添加复选框到节点.I通过使用TVS_CHECKBOXES将复选框添加到所有节点。但事情是我不希望这种激情。我不得不想要添加或删除复选框。任何人都可以帮我完成这项工作。



在此先感谢,

Siva Vuyyuru。

Hi,


I had created a treecontrol using win32.Now i would like to add checkboxes to the nodes randomly .I added the checkboxes to all nodes by using TVS_CHECKBOXES.But the thing is i don't want this in this passion .It had to be up to my wish to add or remove the checkboxes.Can any one help me out to make this done.

Thanks in Advance,
Siva Vuyyuru.

推荐答案

你有树形窗口的句柄我会在代码中将其称为hWnd



添加复选框

You have the handle to the tree window I will call it hWnd in the code

To add the check boxes
DWORD dwStyle = GetWindowLong(hWnd , GWL_STYLE);
dwStyle |= TVS_CHECKBOXES;   // OR THE FLAGS ON
SetWindowLongPtr(hWnd , GWL_STYLE, dwStyle );



删除它们


To remove them

DWORD dwStyle = GetWindowLong(hWnd , GWL_STYLE);
dwStyle &= (~TVS_CHECKBOXES);   // AND NOT THE FLAGS OFF
SetWindowLongPtr(hWnd , GWL_STYLE, dwStyle );





DONT FORGET =>无效或重绘窗口(hWnd)之后更新屏幕上的可视化



DONT FORGET => Invalidate or Redraw the window (hWnd) after it to update the visual on screen


好的,你要的是一个ListBox,每个项目选项复选框



简短的回答是本机WIN32 API中不存在你必须自己构建它的能力。



在MFC框架中它被称为CCheckBoxList,它是完成所有工作的框架。



如果你想解决它,你必须制作一个OWNERDRAW列表框或子类列表框。 />


如果你想要一个破解,你可能想看看我在哪里帮助了另一个正在做一个子类列表框的用户



与TransparentBlt的结果不正确 [ ^ ]
Okay what you are asking for is a ListBox with option of a per item checkbox

Short answer is that ability doesn't exist in native WIN32 API you have to build it yourself.

In the MFC framework it is called a CCheckBoxList and it is the framework doing all the work.

If you want tackle it you have to make an OWNERDRAW list box or subclass the listbox.

If you want to have a crack you may want to look here where I helped another user who was doing a subclassed listbox

Incorrect result with TransparentBlt[^]


这篇关于删除并向树控件中的节点添加复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆