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 detect Listctrl check box selection/deselection

how to detect Listctrl check box selection/deselection

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
9 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.
  • H Offline
    H Offline
    hemlat
    wrote on last edited by
    #1

    Hi, In my application I have created Listctrl on dialog with check box option.I need to handle check box selection or deselection events.Can anyone tell me which message handle I need to take. Regards, Rekha.

    J 1 Reply Last reply
    0
    • H hemlat

      Hi, In my application I have created Listctrl on dialog with check box option.I need to handle check box selection or deselection events.Can anyone tell me which message handle I need to take. Regards, Rekha.

      J Offline
      J Offline
      Jijo Raj
      wrote on last edited by
      #2

      Hello Hamlat, You can use CListCtrl::GetCheck()[^]. Please have a look at this article[^]. Regards, Jijo.

      _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

      H 1 Reply Last reply
      0
      • J Jijo Raj

        Hello Hamlat, You can use CListCtrl::GetCheck()[^]. Please have a look at this article[^]. Regards, Jijo.

        _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

        H Offline
        H Offline
        hemlat
        wrote on last edited by
        #3

        Thanks for your replay. But I need to get check box event selection message handler not whether check box is checked or not.

        S 1 Reply Last reply
        0
        • H hemlat

          Thanks for your replay. But I need to get check box event selection message handler not whether check box is checked or not.

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

          hemlat wrote:

          Thanks for your replay. But I need to get check box event selection message handler not whether check box is checked or not.

          Doesn't matter whether you need it or not - Microsoft don't provide that. What you do have is LVN_ITEMCHANGING[^] and LVN_ITEMCHANGED[^], which are sent when an item changes in any way - it's up to you to determine if that's because a check box has changed from checked to unchecked or unchecked to checked.

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          H 1 Reply Last reply
          0
          • S Stuart Dootson

            hemlat wrote:

            Thanks for your replay. But I need to get check box event selection message handler not whether check box is checked or not.

            Doesn't matter whether you need it or not - Microsoft don't provide that. What you do have is LVN_ITEMCHANGING[^] and LVN_ITEMCHANGED[^], which are sent when an item changes in any way - it's up to you to determine if that's because a check box has changed from checked to unchecked or unchecked to checked.

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            H Offline
            H Offline
            hemlat
            wrote on last edited by
            #5

            Hi, I have used both LVN_ITEMCHANGING and LVN_ITEMCHANGED . But these these are sent not only for check box selection but also for another events like adding items to Listctrl. I have searched for this requirement but I did not get required result. I am not sure whether Microsoft provide this or not. I am new to MFC. Thanks for your reply. I think I need to change logic of my code dependence on existing event handlers.

            C S 2 Replies Last reply
            0
            • H hemlat

              Hi, I have used both LVN_ITEMCHANGING and LVN_ITEMCHANGED . But these these are sent not only for check box selection but also for another events like adding items to Listctrl. I have searched for this requirement but I did not get required result. I am not sure whether Microsoft provide this or not. I am new to MFC. Thanks for your reply. I think I need to change logic of my code dependence on existing event handlers.

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #6

              hemlat wrote:

              I have used both LVN_ITEMCHANGING and LVN_ITEMCHANGED . But these these are sent not only for check box selection but also for another events like adding items to Listctrl.

              From MSDN [^]

              Parameters pnmv Pointer to an NMLISTVIEW structure that identifies the item and specifies which of its attributes are changing.

              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.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              H 1 Reply Last reply
              0
              • H hemlat

                Hi, I have used both LVN_ITEMCHANGING and LVN_ITEMCHANGED . But these these are sent not only for check box selection but also for another events like adding items to Listctrl. I have searched for this requirement but I did not get required result. I am not sure whether Microsoft provide this or not. I am new to MFC. Thanks for your reply. I think I need to change logic of my code dependence on existing event handlers.

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

                hemlat wrote:

                I have used both LVN_ITEMCHANGING and LVN_ITEMCHANGED . But these these are sent not only for check box selection but also for another events like adding items to Listctrl.

                That's right. So you (YOU) need to add code to those handlers to determine whether or not an items check state has changed. Here's a hint - the checkbox is implemented as an state image overlay - look up LVIS_STATEIMAGEMASK in the list-view item state flags.

                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                H 1 Reply Last reply
                0
                • C CPallini

                  hemlat wrote:

                  I have used both LVN_ITEMCHANGING and LVN_ITEMCHANGED . But these these are sent not only for check box selection but also for another events like adding items to Listctrl.

                  From MSDN [^]

                  Parameters pnmv Pointer to an NMLISTVIEW structure that identifies the item and specifies which of its attributes are changing.

                  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.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  H Offline
                  H Offline
                  hemlat
                  wrote on last edited by
                  #8

                  Thanks for your reply.I got it.

                  1 Reply Last reply
                  0
                  • S Stuart Dootson

                    hemlat wrote:

                    I have used both LVN_ITEMCHANGING and LVN_ITEMCHANGED . But these these are sent not only for check box selection but also for another events like adding items to Listctrl.

                    That's right. So you (YOU) need to add code to those handlers to determine whether or not an items check state has changed. Here's a hint - the checkbox is implemented as an state image overlay - look up LVIS_STATEIMAGEMASK in the list-view item state flags.

                    Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                    H Offline
                    H Offline
                    hemlat
                    wrote on last edited by
                    #9

                    Thanks for your reply. I got it.

                    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