开发者

How to programmatically end editing of a CTreeCtrl?

I have a class derived from CTreeCtrl. In some circumstances the user might be editing it and I would like to program开发者_运维百科matically cancel the edit which is currently in progress.

How do I do this? There doesn't seem to be any appropriate function of the class which would do that, or if I have to send it some message it's not immediately obvious to me what the message is that I should send.


I believe this is possible by sending the tree control the TVM_ENDEDITLABELNOW message, or by using the TreeView_EndEditLabelNow macro.


To determine if the user is editing a label, you have to wait for the folling messages: TVN_BEGINLABELEDIT and TVN_ENDLABELEDIT.

To cancel, just set the focus to another node.


So I've eventually discovered that I can fake an Escape button press to the edit control:

tree.GetEditControl()->SendMessage(WM_KEYDOWN, VK_ESCAPE, 1);

This seems to cancel editing appropriately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜