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 label editing problem

List control label editing problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
4 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.
  • L Offline
    L Offline
    L Madhavan
    wrote on last edited by
    #1

    When the user begins editing an item label in a list control, I'd like to select a portion of the text in the edit control. I'm using MFC and currently, I'm calling GetEditControl() in the LVN_BEGINLABELEDIT handler and then using SetSel() to set the selection in the edit control. This works as expected under Vista, but under XP, the code seems to have no effect and nothing is selected. Has anyone come across this behaviour before? Any help towards solving this problem is greatly appreciated.

    C 1 Reply Last reply
    0
    • L L Madhavan

      When the user begins editing an item label in a list control, I'd like to select a portion of the text in the edit control. I'm using MFC and currently, I'm calling GetEditControl() in the LVN_BEGINLABELEDIT handler and then using SetSel() to set the selection in the edit control. This works as expected under Vista, but under XP, the code seems to have no effect and nothing is selected. Has anyone come across this behaviour before? Any help towards solving this problem is greatly appreciated.

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Just an idea, try posting the EM_SETSEL[^] message to the edit instead of calling SetSel() on it directly in the message handler and see if it changes anything.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. <

      L 1 Reply Last reply
      0
      • C Code o mat

        Just an idea, try posting the EM_SETSEL[^] message to the edit instead of calling SetSel() on it directly in the message handler and see if it changes anything.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. <

        L Offline
        L Offline
        L Madhavan
        wrote on last edited by
        #3

        Wonderful, it works! I guess that XP resets the selection after the LVN_BEGINLABELEDIT handler returns, so posting the message did the trick.

        C 1 Reply Last reply
        0
        • L L Madhavan

          Wonderful, it works! I guess that XP resets the selection after the LVN_BEGINLABELEDIT handler returns, so posting the message did the trick.

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Good old PostMessage, it helped me out a few times too. Maybe we should send flowers as a thank, or better, post flowers. :)

          > The problem with computers is that they do what you tell them to do and not what you want them to do. <

          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