TVM_ENDEDITLABELNOW with VK_RETURN or VK_ESCAPE?
-
Hi, I have a _non-MFC_ dialog-based app with a tree view. Everything is working very nicely (thanks to some great code examples by Bengi on this site). However, at the moment the only way of ending the label editing of a tree view item is to click elsewhere in the window. I would like it to behave like Windows Explorer, so that if the user presses Escape or Enter, the TVM_ENDEDITLABELNOW is sent to the treeview and the label editing is ended. However, I cannot get this to work at all. I have tried sending the message under WM_CHAR and WM_KEYDOWN with case VK_RETURN and VK_ESCAPE, but no joy. I have read elsewhere that it is difficult setting this up, but haven't been able to find a solution. Could anybody tell me how I can go about doing this? Many thanks to anyone who can help, KB
-
Hi, I have a _non-MFC_ dialog-based app with a tree view. Everything is working very nicely (thanks to some great code examples by Bengi on this site). However, at the moment the only way of ending the label editing of a tree view item is to click elsewhere in the window. I would like it to behave like Windows Explorer, so that if the user presses Escape or Enter, the TVM_ENDEDITLABELNOW is sent to the treeview and the label editing is ended. However, I cannot get this to work at all. I have tried sending the message under WM_CHAR and WM_KEYDOWN with case VK_RETURN and VK_ESCAPE, but no joy. I have read elsewhere that it is difficult setting this up, but haven't been able to find a solution. Could anybody tell me how I can go about doing this? Many thanks to anyone who can help, KB
Hi, Okay, I found this article on MSDN that discusses this problem: http://support.microsoft.com/default.aspx?scid=kb;en-us;130691 Unfortunately I'm relatively new to coding C++, and I don't know how to go about implementing the advice given in that article. From the article: "To work around this problem, subclass the edit control in response to the TVN_BEGINLABELEDIT notification that is sent by the tree view control when the tree view is about to start label editing for an item. To obtain the edit control's window handle, send the tree view control a TVM_GETEDITCONTROL message. The subclass procedure should handle the WM_GETDLGCODE message by returning DLGC_WANTALLKEYS. This allows the tree view's subclass procedure to handle ESC and ENTER keystrokes." So, if I understand correctly, I need to subclass my tree view control here:
//EDIT LABEL: if(((LPNMHDR)lParam)->code == TVN_BEGINLABELEDIT) { hEdit=TreeView_GetEditControl(hTree); //subclass here??? }
If anybody could tell me how to subclass this and handle the WM_GETDLGCODE message accordingly, I would be very grateful. (_NON-MFC_ :) ) Sorry if this is a really basic question. Many thanks, KB