How to create a listbox in win32 with checkbox style
-
In MFC the above can be done by using CListCtrl class. but how to do the same in win32 ? Please help.
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!
-
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!
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
-
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
A List View Control[^] with the
LVS_REPORT
style set andLVS_EX_CHECKBOXES
extended style might be what you're after. Also remember, as with all common controls, you must call InitCommonControlsEx[^].Steve
-
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
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