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. CListCtrl Get selection?

CListCtrl Get selection?

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxquestion
5 Posts 4 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.
  • J Offline
    J Offline
    Johpoke
    wrote on last edited by
    #1

    Ive gone quite crazy at microsoft for the weirdness of the CListCtrl, I just want to find out the contents of the selection in my list.. I can only find this: short Selected = m_MyList.GetSelectionMark(); But that returns the number of the item, if i fill my list with "Linux" and "Windows" then i would like a method which returns "Windows", or "Linux"... Are there any functions for that?? Thanks! (Using VS6.0 dialog based mfc app...)

    //Johannes

    CPalliniC D 2 Replies Last reply
    0
    • J Johpoke

      Ive gone quite crazy at microsoft for the weirdness of the CListCtrl, I just want to find out the contents of the selection in my list.. I can only find this: short Selected = m_MyList.GetSelectionMark(); But that returns the number of the item, if i fill my list with "Linux" and "Windows" then i would like a method which returns "Windows", or "Linux"... Are there any functions for that?? Thanks! (Using VS6.0 dialog based mfc app...)

      //Johannes

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Try:

      CString sText;
      int nSel;
      nSel = m_MyList.GetSelectionMark();
      if (sel != -1)
      {
      sText = m_MyList.GetItemText(nSel, 0);
      }

      :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      In testa che avete, signor di Ceprano?

      J 1 Reply Last reply
      0
      • CPalliniC CPallini

        Try:

        CString sText;
        int nSel;
        nSel = m_MyList.GetSelectionMark();
        if (sel != -1)
        {
        sText = m_MyList.GetItemText(nSel, 0);
        }

        :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        J Offline
        J Offline
        Johpoke
        wrote on last edited by
        #3

        Thanks, that works great :) My other problem with my CListCtrl is kind of weird... I use NM_CLICK and LVN_KEYDOWN messages, when i use the arrow keys and navigate to the end of the list contents, and try to keep going (ie at the end push down arrow a few more times) i seem to get an offset with 1 (when i go back up), same happens when i go upwards... I think the reason for this is that the LVN_KEYDOWN is not the message i want, as it seems to be called before the selection mark has changed, which message do i want? :^) Thanks :-D

        //Johannes

        N 1 Reply Last reply
        0
        • J Johpoke

          Thanks, that works great :) My other problem with my CListCtrl is kind of weird... I use NM_CLICK and LVN_KEYDOWN messages, when i use the arrow keys and navigate to the end of the list contents, and try to keep going (ie at the end push down arrow a few more times) i seem to get an offset with 1 (when i go back up), same happens when i go upwards... I think the reason for this is that the LVN_KEYDOWN is not the message i want, as it seems to be called before the selection mark has changed, which message do i want? :^) Thanks :-D

          //Johannes

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

          Can't you check if actual item is different of first / last item before moving?

          Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

          1 Reply Last reply
          0
          • J Johpoke

            Ive gone quite crazy at microsoft for the weirdness of the CListCtrl, I just want to find out the contents of the selection in my list.. I can only find this: short Selected = m_MyList.GetSelectionMark(); But that returns the number of the item, if i fill my list with "Linux" and "Windows" then i would like a method which returns "Windows", or "Linux"... Are there any functions for that?? Thanks! (Using VS6.0 dialog based mfc app...)

            //Johannes

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Johpoke wrote:

            short Selected = m_MyList.GetSelectionMark();

            Are you using a multiselect list control?

            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            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