treeview control, NM_RETURN and dialog boxes

treeview control, NM_RETURN and dialog boxes

Post by Jonathan W » Sat, 10 Nov 2007 11:11:00


I have a treeview control on a dialog box. Per MSDN, pressing enter on the
treeview should send a NM_RETURN. However, I am not receiving the NM_RETURN
message. Whats wrong? How do I get the treeview to give me the NM_RETURN
message?

Do I need to subclass the treeview and handle WM_KEYDOWN for VK_RETURN myself?

Do I need to subclass the treeview and handle WM_GETDLGCODE?
 
 
 

treeview control, NM_RETURN and dialog boxes

Post by Kellie Fit » Sat, 10 Nov 2007 11:53:53


Hi,

You can handle the following tree-view notification and
Windows messages and process the virtual key (VK_RETURN):

TVN_KEYDOWN

WM_KEYDOWN

WM_CHAR

http://www.yqcomputer.com/

http://www.yqcomputer.com/

http://www.yqcomputer.com/

http://www.yqcomputer.com/

Kellie.

 
 
 

treeview control, NM_RETURN and dialog boxes

Post by Jonathan W » Sat, 10 Nov 2007 12:24:00

> TVN_KEYDOWN
Tried that, the dialog box is never sent a TVN_KEYDOWN for VK_RETURN either.

What I see with spy++ is that the tree control gets a WM_KEYDOWN for
VK_RETURN. Then I see the tree control handling WM_GETDLGCODE with values
of DLGC_WANTARROWS and DLGC_WANTCHARS
It would seem as though a treeview control on a dialog box says "I want
arrow keys and characters only" which causes it not to get the enter key
and therefore not send a NM_RETURN.
Maybe I need to subclass the treeview and handle WM_GETDLGCODE to say "yes,
please give this treeview the enter key"
 
 
 

treeview control, NM_RETURN and dialog boxes

Post by Jonathan W » Sat, 10 Nov 2007 13:02:37

Ok, I was able to get it working by using SetWindowSubclass to subclass the
treeview then looking for WM_GETDLGCODE being called for WM_KEYDOWN with
VK_RETURN and returning DLGC_WANTMESSAGE when that happens.