Solved

Allowing user editing on CTreeCtrl

Posted on 1998-10-01
6
431 Views
Last Modified: 2013-11-20
Easy Question:
How to I allow the user to edit the items in a tree control
I have set the window style on creation, but how do I start
the edit process off - so I can receive the messages (start and end edit)?? Has anyone some source for me to look at??
0
Comment
Question by:dd021197
6 Comments
 
LVL 1

Expert Comment

by:timop
ID: 1322805
To allow the user to edit the items you must use TVS_EDITLABELS style.

m_treeCtrl.ModifyStyle(0, TVS_EDITLABELS ); // editing is allowed

When label editing begins, a tree view control sends its parent window a TVN_BEGINLABELEDIT notification message.
When label editing is canceled or completed, a tree view control sends its parent window a TVN_ENDLABELEDIT notification message.
0
 
LVL 1

Author Comment

by:dd021197
ID: 1322806
Thanks, the message is now sent. But I still don't understand
how the editing takes place - I want to set it up like explorer
what code do I put where? Do I handle the CEdit control or
is that taken care of. All I have done is set the style on
creation and modified the style. The messages are being called
okay now - but I still can't actually edit the labels.


0
 
LVL 1

Author Comment

by:dd021197
ID: 1322807
The points are yours timop if I can get a bit more info.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Expert Comment

by:umarama
ID: 1322808
Hi dd !

Handle some mouse or keyboard event (dbl click / Enter /etc) where you wish to activate your editing. Enter the following line

CEdit * pEdit = EditLabel();

CTreeCtrl manages the Edit control. If you wish, you can subclass the edit control in OnBeginLabelEdit() using GetEditCtrl().

Now put code for OnBeginLabelEdit() & OnEndLabelEdit(). You can use GetEditCtrl() to retrieve ptr to this edit control. Use any of the edit controls functions.

Use TV_DISPINFO structure on OnEndLabelEdit to retrieve all sorts of info. Refer documentation. You are responsible for updating the item's label, if appropriate, perhaps after validating the edited string. The pszText member of TV_ITEM is 0 if editing is canceled.

Say what, you should refer to the following documentation.
"Tree Control Label Editing"

If you have any questions regarding Subclassing the edit control, I will gladly help you.
0
 
LVL 2

Accepted Solution

by:
cramer091498 earned 50 total points
ID: 1322809
look at
http://www.codeguru.com/treeview/index.shtml
for a sample solution
0
 
LVL 1

Author Comment

by:dd021197
ID: 1322810
the points are yours

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now