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. Item changed event in CListCtrl

Item changed event in CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 2 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.
  • T Offline
    T Offline
    tataxin
    wrote on last edited by
    #1

    I create a List ctrl derivered from CListCtrl. In this class, I implement item changed event

    class CMyListCtrl :
    public CListCtrl

    ....
    BEGIN_MESSAGE_MAP(CMyListCtrl, CListCtrl)
    ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, &CTrendListCtrl::OnLvnItemchanged)
    END_MESSAGE_MAP()

    ......
    void CMyListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult) // (1)
    {
    ..
    }

    Then, on my dialog, there's a CMyListCtrl object, like this

    CMyListCtrl m_lst;

    afx_msg void OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult);

    I try to implement the item changed on that list.

    BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
    ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_GROUP, &CMyDlg::OnLvnItemchangedList)
    END_MESSAGE_MAP()

    void CMyDlg::OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult) // (2)
    {
    ...
    }

    The problem is, if I implement (1), then it doesn't run (2). And if I doesn't implement (1), it can run (2). Actually I want to run both (1) and (2). What should I do in this case? Thank you very much, bro.

    L T 2 Replies Last reply
    0
    • T tataxin

      I create a List ctrl derivered from CListCtrl. In this class, I implement item changed event

      class CMyListCtrl :
      public CListCtrl

      ....
      BEGIN_MESSAGE_MAP(CMyListCtrl, CListCtrl)
      ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, &CTrendListCtrl::OnLvnItemchanged)
      END_MESSAGE_MAP()

      ......
      void CMyListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult) // (1)
      {
      ..
      }

      Then, on my dialog, there's a CMyListCtrl object, like this

      CMyListCtrl m_lst;

      afx_msg void OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult);

      I try to implement the item changed on that list.

      BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
      ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_GROUP, &CMyDlg::OnLvnItemchangedList)
      END_MESSAGE_MAP()

      void CMyDlg::OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult) // (2)
      {
      ...
      }

      The problem is, if I implement (1), then it doesn't run (2). And if I doesn't implement (1), it can run (2). Actually I want to run both (1) and (2). What should I do in this case? Thank you very much, bro.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try changing ON_NOTIFY_REFLECT to ON_NOTIFY_REFLECT_EX and return TRUE inside your CMyListCtrl::OnLvnItemchanged handler. Best Wishes, -David Delaune

      T 1 Reply Last reply
      0
      • L Lost User

        Try changing ON_NOTIFY_REFLECT to ON_NOTIFY_REFLECT_EX and return TRUE inside your CMyListCtrl::OnLvnItemchanged handler. Best Wishes, -David Delaune

        T Offline
        T Offline
        tataxin
        wrote on last edited by
        #3

        uhm, I'm not sure that ... Is this what you mean:

        ON_NOTIFY_REFLECT_EX(LVN_ITEMCHANGED, &CMyListCtrl::OnLvnItemchanged)

        BOOL CMyListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
        {
        // TODO: Add your control notification handler code here
        LPNMLISTVIEW pNMLV = reinterpret_cast(pNMHDR);
        *pResult = 0;
        ....
        return TRUE;
        }

        I cannot see any change ..... :(

        L 1 Reply Last reply
        0
        • T tataxin

          uhm, I'm not sure that ... Is this what you mean:

          ON_NOTIFY_REFLECT_EX(LVN_ITEMCHANGED, &CMyListCtrl::OnLvnItemchanged)

          BOOL CMyListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
          {
          // TODO: Add your control notification handler code here
          LPNMLISTVIEW pNMLV = reinterpret_cast(pNMHDR);
          *pResult = 0;
          ....
          return TRUE;
          }

          I cannot see any change ..... :(

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Maybe you need to return FALSE inside the handler rather than TRUE. See if this MSDN article helps: http://msdn.microsoft.com/en-us/library/eeah46xd(VS.71).aspx[^] Best Wishes, -David Delaune

          T 1 Reply Last reply
          0
          • L Lost User

            Maybe you need to return FALSE inside the handler rather than TRUE. See if this MSDN article helps: http://msdn.microsoft.com/en-us/library/eeah46xd(VS.71).aspx[^] Best Wishes, -David Delaune

            T Offline
            T Offline
            tataxin
            wrote on last edited by
            #5

            uhm, I already tried return FALSE, but it's not better. .. I will try this a litter bit later. Thank you very much, David Delaune.

            1 Reply Last reply
            0
            • T tataxin

              I create a List ctrl derivered from CListCtrl. In this class, I implement item changed event

              class CMyListCtrl :
              public CListCtrl

              ....
              BEGIN_MESSAGE_MAP(CMyListCtrl, CListCtrl)
              ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, &CTrendListCtrl::OnLvnItemchanged)
              END_MESSAGE_MAP()

              ......
              void CMyListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult) // (1)
              {
              ..
              }

              Then, on my dialog, there's a CMyListCtrl object, like this

              CMyListCtrl m_lst;

              afx_msg void OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult);

              I try to implement the item changed on that list.

              BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
              ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_GROUP, &CMyDlg::OnLvnItemchangedList)
              END_MESSAGE_MAP()

              void CMyDlg::OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult) // (2)
              {
              ...
              }

              The problem is, if I implement (1), then it doesn't run (2). And if I doesn't implement (1), it can run (2). Actually I want to run both (1) and (2). What should I do in this case? Thank you very much, bro.

              T Offline
              T Offline
              tataxin
              wrote on last edited by
              #6

              does any one have any idea in this case??? help me, please!!!

              T 1 Reply Last reply
              0
              • T tataxin

                does any one have any idea in this case??? help me, please!!!

                T Offline
                T Offline
                tataxin
                wrote on last edited by
                #7

                maybe the best way is avoid it. It's terrible the way MFC handle an event, :( anyway, thank you very much, Randor!!

                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