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. List control ignores FindItem?

List control ignores FindItem?

Scheduled Pinned Locked Moved C / C++ / MFC
testingbeta-testinghelpquestion
5 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.
  • N Offline
    N Offline
    nobaq
    wrote on last edited by
    #1

    Hi, I have an (owner drawn) list control and handle the LVN_ODFINDITEM message. For testing purposes:

    void CIndexDlg::OnLvnOdfinditemData(NMHDR *pNMHDR, LRESULT *pResult)
    {
    LPNMLVFINDITEM pFindInfo = reinterpret_cast(pNMHDR);
    *pResult = (rand() % 999) + 1;
    }

    This works good when typing something inside the control. But now I also want to have an external way to find an entry. So I places an edit control in the dialog and want to call FindItem manually:

    LVFINDINFO fi;
    ZeroMemory(&fi, sizeof(fi));
    fi.flags = LVFI_PARTIAL | LVFI_STRING;
    fi.psz = m_strWhat;

    m_ctrlData.FindItem(&fi);
    //m_ctrlData.SendMessage(LVM_FINDITEM, -1, (LPARAM)&fi);

    But in this case, my OnLvnOdfinditemData handler never gets called! I also tried sending manually with SendMessage but it did not work either. What could be the problem?

    S 1 Reply Last reply
    0
    • N nobaq

      Hi, I have an (owner drawn) list control and handle the LVN_ODFINDITEM message. For testing purposes:

      void CIndexDlg::OnLvnOdfinditemData(NMHDR *pNMHDR, LRESULT *pResult)
      {
      LPNMLVFINDITEM pFindInfo = reinterpret_cast(pNMHDR);
      *pResult = (rand() % 999) + 1;
      }

      This works good when typing something inside the control. But now I also want to have an external way to find an entry. So I places an edit control in the dialog and want to call FindItem manually:

      LVFINDINFO fi;
      ZeroMemory(&fi, sizeof(fi));
      fi.flags = LVFI_PARTIAL | LVFI_STRING;
      fi.psz = m_strWhat;

      m_ctrlData.FindItem(&fi);
      //m_ctrlData.SendMessage(LVM_FINDITEM, -1, (LPARAM)&fi);

      But in this case, my OnLvnOdfinditemData handler never gets called! I also tried sending manually with SendMessage but it did not work either. What could be the problem?

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2
      1. Could you use Spy++ to investigate what messages (with wparam and lparam? Not sure if Spy++ tracks those) are sent when doing an incremental search using the keyboard
      2. Have you verified your FindItem call is successful with a non-virtual/non-owner data list control?

      Aside from that, can't see as you're doing anything wrong :-(

      N 1 Reply Last reply
      0
      • S Stuart Dootson
        1. Could you use Spy++ to investigate what messages (with wparam and lparam? Not sure if Spy++ tracks those) are sent when doing an incremental search using the keyboard
        2. Have you verified your FindItem call is successful with a non-virtual/non-owner data list control?

        Aside from that, can't see as you're doing anything wrong :-(

        N Offline
        N Offline
        nobaq
        wrote on last edited by
        #3

        Hi and thank you for the help! I tried it with Spy++ and for testing, I typed an 'a'. The message is sent:

        <00004> 00070E74 S LVM_FINDITEMA iStart:-1 plvfi:0012E8D8
        <00005> 00070E74 R LVM_FINDITEMA iIndex: 86

        I really don't know why my message handler is not called :-( Niki

        N 1 Reply Last reply
        0
        • N nobaq

          Hi and thank you for the help! I tried it with Spy++ and for testing, I typed an 'a'. The message is sent:

          <00004> 00070E74 S LVM_FINDITEMA iStart:-1 plvfi:0012E8D8
          <00005> 00070E74 R LVM_FINDITEMA iIndex: 86

          I really don't know why my message handler is not called :-( Niki

          N Offline
          N Offline
          nobaq
          wrote on last edited by
          #4

          I know what is my error: FindItem and SendMessage(LVM_FINDITEMA) only gives back the index of the found item but the control does not scroll automatically to that position. Is there a way to implement this? I already tried UpdateWindow() and also SetSelectionMark()... Thank you!

          S 1 Reply Last reply
          0
          • N nobaq

            I know what is my error: FindItem and SendMessage(LVM_FINDITEMA) only gives back the index of the found item but the control does not scroll automatically to that position. Is there a way to implement this? I already tried UpdateWindow() and also SetSelectionMark()... Thank you!

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

            That I can help you with :-) CListCtrl::EnsureVisible makes a specified item visible. CListCtrl::Scroll gives you more control over how the list control's view is altered.

            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