Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

In original MFC's CTreeCtrl, when i click a tree item, tree expands or collapses it only if hit point is inside the item's text area.

How can i change active area to size of full item's row instead of text's area?

Thanks in advances.

Quy
Posted

1 solution

It looks like you cannot do it, unless you create your own tree control.

—SA
 
Share this answer
 
Comments
quyps 30-May-11 2:51am    
"Create your own tree control", Do you mean that i need to make a customized CTreeCtrl? If so, which message do i need to handle in order todo it?
Thanks.
Sergey Alexandrovich Kryukov 30-May-11 13:58pm    
Unfortunately not. If I could do that I would probably advise how to do it in detail.
Unfortunately, this is all based on old slow and sometimes flickering Windows control (window class) which fundamentally uses the input region it uses. I mean completely from scratch. There are projects like that created out of desperation about unsatisfactory tree control. I don't know such controls in MFC though.
--SA
Sergey Alexandrovich Kryukov 30-May-11 14:04pm    
I have another idea, but the ugly one. You can make the tree control completely owner-draw, but based on CTreeCtrl. Fill it with long "fake" strings feeling the width of control (this is not so easy, because the strings should not be too long (otherwise you horizontal scroll bar will be always visible, but you can use monospace font). The tree view will be sensitive to node click in the full width. In owner draw, draw "real" strings and whatever graphical elements you need. Not very nice way, I know. That's why I'm not putting in in the solution.

There is no easy way.
--SA
quyps 2-Jun-11 1:10am    
Thank Kryukov! Can you point me one of projects like that?
I have been thinking of customizing CTreeCtrl and handling "double click" event. I haven't try yet, but it sounds promising.
Sergey Alexandrovich Kryukov 2-Jun-11 1:58am    
Sorry, the only project like that is in Delphi (Delphi Pascal). It's the wonderful project though, called "VirtualTreeView". If I new it in C++ I would gave you a link right away. If you could use Delphi (and this thing is not free) you could wrap it in a plain DLL and use in C++. There is also FreePascal with Delphi-compatible mode, but I don't know how usable it would be together. Interested? I fear not very much.

The lack of really good Tree View really haunts me. I cannot afford such a big work right now. I've done big work around for .NET tree view by making it 100% owner-draw (per-node owner draw exposed huge flicker, so I had to through it out). But much bigger problem is the lack of virtual mode, which is available for grid view and list view. Windows window class based TreeView is the piece of old legacy which should have been trashed years ago, but Microsoft cannot offer anything better.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900