Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get NM_RETURN notify event from CListCtrl

How to get NM_RETURN notify event from CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nitheesh George
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • N Nitheesh George

      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

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      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 an OnDlgCode 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 of CListCtrl in MFC dialogs and the dialog will be sent NM_RETURN notifications.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      N I 2 Replies Last reply
      0
      • S Stuart Dootson

        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 an OnDlgCode 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 of CListCtrl in MFC dialogs and the dialog will be sent NM_RETURN notifications.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        N Offline
        N Offline
        Nitheesh George
        wrote on last edited by
        #3

        Hi Stuart, thank you for your reply. i will try this. thanks Jose Jo

        Jose Jo Martin http://www.simpletools.co.in

        1 Reply Last reply
        0
        • S Stuart Dootson

          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 an OnDlgCode 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 of CListCtrl in MFC dialogs and the dialog will be sent NM_RETURN notifications.

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          I Offline
          I Offline
          infiro
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups