PRB: ESC and ENTER Keys Do Not Work When You Edit Labels in TreeView (130691)



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0

This article was previously published under Q130691

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 that is created by the TreeView control. The result is that the keystrokes have no effect.

CAUSE

The tree view control creates and subclasses the edit control that is used for in-place editing. The subclass procedure does not handle the WM_GETDLGCODE message that is sent by IsDialogMessage, which results in default handling of the keystrokes by IsDialogMessage.

RESOLUTION

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.

Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbCtrl kbprb kbTreeView KB130691