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 let the CListCtrl selected

How to let the CListCtrl selected

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
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.
  • B Offline
    B Offline
    bghuang
    wrote on last edited by
    #1

    There are many object in the same windows,How to let the CListCtrl selected by program othe than by tne mouse?

    A J 2 Replies Last reply
    0
    • B bghuang

      There are many object in the same windows,How to let the CListCtrl selected by program othe than by tne mouse?

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      i is the item number in the list you want to select SetItemState(i, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);

      B 1 Reply Last reply
      0
      • A Anonymous

        i is the item number in the list you want to select SetItemState(i, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);

        B Offline
        B Offline
        bghuang
        wrote on last edited by
        #3

        I try,but faild.

        1 Reply Last reply
        0
        • B bghuang

          There are many object in the same windows,How to let the CListCtrl selected by program othe than by tne mouse?

          J Offline
          J Offline
          Jose Lamas Rios
          wrote on last edited by
          #4

          If you have a pointer to the CListCtrl object, you can simply use CWnd::SetFocus[^] this way:

          m_pListCtrl.SetFocus();

          If you don't have a pointer to the CListCtrl, you can use CWnd::GetDlgItem [^] on the parent window to obtain one.

          CTheControlParent::SetFocusOnListCtrl()
          {
            CWnd* pWnd = GetDlgItem(THE_ID_OF_THE_LIST_CTRL);
            if (pWnd != NULL)
            pWnd->SetFocus()
          }

          Hope that helps, -- jlr http://jlamas.blogspot.com/[^]

          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