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 create a listbox in win32 with checkbox style

How to create a listbox in win32 with checkbox style

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

    In MFC the above can be done by using CListCtrl class. but how to do the same in win32 ? Please help.

    I 1 Reply Last reply
    0
    • N nbugalia

      In MFC the above can be done by using CListCtrl class. but how to do the same in win32 ? Please help.

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      There is no easy way. There is no "check" style for a listbox - there's an MFC class which does clever things for you. Have a look at the code for CCheckListBox, and you'll see it actually does owner draw for the listbox. I can't remember how it stores the check state - either as item data, or an internal map. So, you'll have to learn how to do owner draw in Win32 (just a case of setting the right styles and responding to a couple of messages) and implement the functionality yourself. If I were you, I'd grab large sections of the work from CCheckListBox - but you'll still have quite a bit of effort to do. Good luck! Iain.

      In the process of moving to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!

      N 1 Reply Last reply
      0
      • I Iain Clarke Warrior Programmer

        There is no easy way. There is no "check" style for a listbox - there's an MFC class which does clever things for you. Have a look at the code for CCheckListBox, and you'll see it actually does owner draw for the listbox. I can't remember how it stores the check state - either as item data, or an internal map. So, you'll have to learn how to do owner draw in Win32 (just a case of setting the right styles and responding to a couple of messages) and implement the functionality yourself. If I were you, I'd grab large sections of the work from CCheckListBox - but you'll still have quite a bit of effort to do. Good luck! Iain.

        In the process of moving to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!

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

        Thanks for the reply Iain. I think we can use ListControl in place of listbox. When I am using ListControl on the dialog, the dialog is not becoming visible. Does anyone have some idea about it ? Can I use ListControl in a win32 application to show the checkbox. Thanks in advance

        S D 2 Replies Last reply
        0
        • N nbugalia

          Thanks for the reply Iain. I think we can use ListControl in place of listbox. When I am using ListControl on the dialog, the dialog is not becoming visible. Does anyone have some idea about it ? Can I use ListControl in a win32 application to show the checkbox. Thanks in advance

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          A List View Control[^] with the LVS_REPORT style set and LVS_EX_CHECKBOXES extended style might be what you're after. Also remember, as with all common controls, you must call InitCommonControlsEx[^].

          Steve

          1 Reply Last reply
          0
          • N nbugalia

            Thanks for the reply Iain. I think we can use ListControl in place of listbox. When I am using ListControl on the dialog, the dialog is not becoming visible. Does anyone have some idea about it ? Can I use ListControl in a win32 application to show the checkbox. Thanks in advance

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

            nbugalia wrote:

            When I am using ListControl on the dialog, the dialog is not becoming visible.

            Can you elaborate, please? :confused:

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            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