Microsoft KB Archive/130691

From BetaArchive Wiki

PRB: ESC/ENTER Keys Do Not Work When Editing Labels in TreeView

Q130691



The information in this article applies to:


  • Microsoft Win32 Software Development Kit (SDK)





SYMPTOMS

When you edit labels in a TreeView control, you should be able to press the ESC key to cancel the changes or press the ENTER key to accept the changes. However, when the TreeView control is contained in a dialog box, IsDialogMessage processes the ESC and ENTER keystrokes and does not pass them on to the edit control created by the TreeView control, so the keystrokes have no effect.



CAUSE

The TreeView control creates and subclasses the edit control used for in-place editing. The subclass procedure does not process the WM_GETDLGCODE and WM_CHAR messages for the edit control properly.



RESOLUTION

To work around the problem, subclass the edit control and return DLGC_WANTALLKEYS in response to the WM_GETDLGCODE message. Then process the WM_CHAR messages for VK_ESCAPE and VK_RETURN.

To subclass the edit control, obtain the handle to the edit control by using the TVM_GETEDITCONTROL message, then use normal subclassing techniques. The control should be subclassed in response to the TVN_BEGINLABELEDIT notification. Remove the subclassing when the TVN_ENDLABELEDIT notification is received.

In response to the WM_CHAR|VK_ESCAPE message, have the application send the TVM_ENDEDITLABELNOW with fCancel = TRUE message to cancel the edit. In response to the WM_CHAR|VK_RETURN message, have the application send the TVM_ENDEDITLABELNOW with fCancel = FALSE message to accept the edit.

All other WM_CHAR messages should be passed on to the default edit control window procedure.

Additional query words:

Keywords : kbCtrl kbOSWinNT kbOSWin2000 kbTreeView kbGrpDSUser
Issue type : kbprb
Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch


Last Reviewed: July 7, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.