473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

checkbox in CListCtrl

100 100+
Hi,
I have many check boxes in a list control.My problem is to uncheck the check box if there is a check box already checked.How can i do??..I tried doing the below but it checks the first check box and unchecks the others.

Expand|Select|Wrap|Line Numbers
  1. void SomeClass::OnCheckboxChanged
  2. ( NMHDR*                  pNMHeader,
  3.   LRESULT*                pResult )
  4. {
  5. func();
  6. }
  7. bool SomeClass::func
  8. (void)
  9. {
  10.   CListCtrl* a_pStatus = (CListCtrl*) GetDlgItem(IDC_DLG_FWUPDATE);
  11.     OC_ULong_t a_NoChecked=0;
  12.   for(OC_ULong_t  a_Index=0;a_Index<a_pStatus->GetItemCount() ;a_Index++)
  13.   {
  14.     // See if the check was selected
  15.     if(a_pStatus->GetItemState(a_Index,LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK(2))
  16.     {
  17.             a_NoChecked++;
  18.             if(a_NoChecked>1)
  19.                 a_pStatus->SetCheck(a_Index,false);
  20.  
  21.     }
  22.   }
  23.     //if(a_NoChecked==1)
  24.     //  return true;
  25.             //else
  26.             //return false;
  27.   return true;
  28. }
  29.  
Jan 29 '08 #1
1 6560
Studlyami
464 Expert 256MB
Why are you manually handling the check boxes?

when creating the CListCtrl Set the style of the list control to use checkboxes. If you want to do something manually when the list item gets checked call the base class for handling the checkbox then do what you want (or vise versa).

If you want to handle the checkbox manually take a look at the default code and see what the difference is.
Jan 30 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Joseph Smith | last post by:
Well I just started playing with VC++ yesterday, so keep it simple if you can. thx. Anyway, I'm having problems with a CListCtrl in report view. The first column seems to display fine, but the...
2
by: Chandrakanth | last post by:
How to make the selection in CListCtrl to appear in different color?
2
by: Herbert VON GRÜNENWALD | last post by:
Hi everyone ! I would like to set an ListViewItem at a special position, into a ListView. There is Bounds, but it's a propertie, that can be only get ! (i could to that in MFC with...
0
by: Rajko | last post by:
Here is something I find unusual. I implemented Drag and Drop to CListCtrl. First I created my own class myCListCtrl from CListCtrl. I implemented OnMouseMove and OnLButtonUp message handlers...
0
by: Ryan Albarelli | last post by:
Here's one I've spent the last 6 hours trying to figure out... I have a CListCtrl derived class. The first time I click an item in the list to select it, I see a lot of multimedia dll's being...
0
by: Victor | last post by:
Hi everybody! VS.NET 2003 C++ MFC project for Windows XP I would like to use a CListCtrl control in a dialog. So I have #include'd "afxcmn.h" in my CMyDialog.h and declared a variable...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
1
by: ggkk | last post by:
How do you prevent a user from resizing the column width of a clistctrl (report view)?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.