Just a small tip. When we want to trap Enter key in a control, we usually have
to sub-class the control and compare WM_KEYDOWN's wParam against VK_RETURN. To
get it there, we also have to trap WM_GETDLGCODE and return DLGC_WANTALLKEYS.
Okay, so far all good. We get VK_ENTER, can act on it, but in some controls we
also get an annoying "ping" from the system. I've just struggled with this in
a TreeView control. No matter what I did or returned in WM_KEYDOWN, system still
pinged on Enter-key. Finally tested to use WM_GETDLGCODE directly in TreeView's
sub-class procedure, like:
Voila! No need to return anything or involve WM_KEYDOWN at all. Works
fine and no more annoying ping on Enter key.
Haven't worked much with the treeview control before, so may be other ways
to trap Enter-key? Used only way I know, but just couldn't get rid of that
stupid ping, until I tested the above. Now it keeps its big mouth shut..
------------------
to sub-class the control and compare WM_KEYDOWN's wParam against VK_RETURN. To
get it there, we also have to trap WM_GETDLGCODE and return DLGC_WANTALLKEYS.
Okay, so far all good. We get VK_ENTER, can act on it, but in some controls we
also get an annoying "ping" from the system. I've just struggled with this in
a TreeView control. No matter what I did or returned in WM_KEYDOWN, system still
pinged on Enter-key. Finally tested to use WM_GETDLGCODE directly in TreeView's
sub-class procedure, like:
Code:
CASE %WM_GETDLGCODE IF wParam = %VK_RETURN THEN 'expand/collapse selected item by code, if possible.. END IF
fine and no more annoying ping on Enter key.
Haven't worked much with the treeview control before, so may be other ways
to trap Enter-key? Used only way I know, but just couldn't get rid of that
stupid ping, until I tested the above. Now it keeps its big mouth shut..

------------------
Comment