How to get NM_RETURN notify event from CListCtrl
-
Hi, I am developing an application in which i want to know whether an Enter key is pressed, if so want to show the user Edit window for that particular entry in ListView.Is there any way to get the NM_RETURN notify event from CListCtrl. I am using VC++ to develop the application. thanks Jose Jo
Jose Jo Martin http://www.simpletools.co.in
-
Hi, I am developing an application in which i want to know whether an Enter key is pressed, if so want to show the user Edit window for that particular entry in ListView.Is there any way to get the NM_RETURN notify event from CListCtrl. I am using VC++ to develop the application. thanks Jose Jo
Jose Jo Martin http://www.simpletools.co.in
To do this, the list-view needs to tell the system that it'll process all keys it's sent (which it can do when it's sent the
WM_GETDLGCODE
message) Easiest way is to sub-class the list control and add anOnDlgCode
override, like this:// In header
class ListControlThatSendsNM_RETURN : public CListCtrl
{
DECLARE_MESSAGE_MAP();
UINT OnGetDlgCode()
};// In .cpp file
BEGIN_MESSAGE_MAP(ListControlThatSendsNM_RETURN, CListCtrl)
ON_WM_GETDLGCODE()
END_MESSAGE_MAP()
UINT ListControlThatSendsNM_RETURN::OnGetDlgCode()
{
return DLGC_WANTALLKEYS;
}then you can use
ListControlThatSendsNM_RETURN
instead ofCListCtrl
in MFC dialogs and the dialog will be sentNM_RETURN
notifications.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
To do this, the list-view needs to tell the system that it'll process all keys it's sent (which it can do when it's sent the
WM_GETDLGCODE
message) Easiest way is to sub-class the list control and add anOnDlgCode
override, like this:// In header
class ListControlThatSendsNM_RETURN : public CListCtrl
{
DECLARE_MESSAGE_MAP();
UINT OnGetDlgCode()
};// In .cpp file
BEGIN_MESSAGE_MAP(ListControlThatSendsNM_RETURN, CListCtrl)
ON_WM_GETDLGCODE()
END_MESSAGE_MAP()
UINT ListControlThatSendsNM_RETURN::OnGetDlgCode()
{
return DLGC_WANTALLKEYS;
}then you can use
ListControlThatSendsNM_RETURN
instead ofCListCtrl
in MFC dialogs and the dialog will be sentNM_RETURN
notifications.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Hi Stuart, thank you for your reply. i will try this. thanks Jose Jo
Jose Jo Martin http://www.simpletools.co.in
-
To do this, the list-view needs to tell the system that it'll process all keys it's sent (which it can do when it's sent the
WM_GETDLGCODE
message) Easiest way is to sub-class the list control and add anOnDlgCode
override, like this:// In header
class ListControlThatSendsNM_RETURN : public CListCtrl
{
DECLARE_MESSAGE_MAP();
UINT OnGetDlgCode()
};// In .cpp file
BEGIN_MESSAGE_MAP(ListControlThatSendsNM_RETURN, CListCtrl)
ON_WM_GETDLGCODE()
END_MESSAGE_MAP()
UINT ListControlThatSendsNM_RETURN::OnGetDlgCode()
{
return DLGC_WANTALLKEYS;
}then you can use
ListControlThatSendsNM_RETURN
instead ofCListCtrl
in MFC dialogs and the dialog will be sentNM_RETURN
notifications.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Thanks you alot. This is the Answer. Without overriding this function, the NM_RETURN or WM_KEYDOWN wont get sent, and you need to both Press Mouse button AND Enter key to have those messages sent. With this overrided function, you only need to press Enter key. One more note I found useful is that: If u r not using CListView, but have a Pane (DockablePane) who is the parent of the CListCtrl; and you want the Pane to handle Notify Messages from the CListCtrl. The best way to do is: 1) Override your CListCtrl, and handle ON_NOTIFY_REFLECT_EX( notifyMessage, memFunction) (notifyMessage could be NM_RETURN) 2) In memFunction, just return FALSE. Which allows this notifyMessage will be handled in other places as well( for ex CListView's Parent). 3) In the Parent class (DockablePane), handle ON_NOTIFY(notifyMessage, ChildID, memFunction) Thanks you