Click here to Skip to main content
15,910,411 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: updateAllViews() not in class wizard?? Pin
ns10-Jul-02 2:26
ns10-Jul-02 2:26 
GeneralRe: updateAllViews() - quick question Pin
peterchen10-Jul-02 4:03
peterchen10-Jul-02 4:03 
GeneralSockect Programming in C Pin
vin10-Jul-02 1:50
vin10-Jul-02 1:50 
GeneralRe: Sockect Programming in C Pin
Nish Nishant10-Jul-02 2:00
sitebuilderNish Nishant10-Jul-02 2:00 
GeneralRe: Sockect Programming in C Pin
Brian Azzopardi10-Jul-02 3:10
Brian Azzopardi10-Jul-02 3:10 
GeneralRe: Sockect Programming in C Pin
Marshall10-Jul-02 3:15
Marshall10-Jul-02 3:15 
Generallist control with checkboxes - newbie Pin
ns10-Jul-02 1:37
ns10-Jul-02 1:37 
GeneralRe: list control with checkboxes - newbie Pin
Mike Upton10-Jul-02 4:08
Mike Upton10-Jul-02 4:08 
You can't make the list control do that automatically (there's no style bit or extended style bit to do it) so you'll have to add some code.

You need a notify handler for NM_CLICK. If the user left clicks on the icon or the first column label, the NMITEMACTIVATE.iItem member will contain the index of the item clicked on, so you can then set the check state of the item.

In MFC, your code will look something like this, assuming you're handling the notification in the parent window of the list control:
//In the message map of the parent window
ON_NOTIFY(NM_CLICK, ID_YOUR_LIST_CONTROL, OnClickYourListControl)

...

//Handler function
void OnClickYourListControl(NMHDR* pNMHDR, LRESULT* pResult)
{
  NMITEMACTIVATE* pItem = (NMITEMACTIVATE*)pNMHDR;

  //If the user clicked on the icon or the first column, iItem is valid
  if (pItem->iItem > -1)
  {
    //You'll probably have a pointer to the list control, but if not...
    CListCtrl* pList = (CListCtrl*)CWnd::FromHandle( (pItem->hdr).hwndFrom );
    ASSERT(pList!=NULL);

    //Toggle the check state
    pList->SetCheck( pItem->iItem, !pList->GetCheck(pItem->iItem) );
  }

  //Doesn't matter what you do with pResult
  *pResult=0;
}


If you're handling the notification in the list control itself, you'll need to use the reflected message instead, via the ON_NOTIFY_REFLECT macro.



"We are the knights who say Ni" (The Knights Who Say Ni)
GeneralRe: list control with checkboxes Thanks!!! Pin
ns10-Jul-02 4:24
ns10-Jul-02 4:24 
Generalstarting the MDI app with two views - beginner Pin
ns10-Jul-02 1:34
ns10-Jul-02 1:34 
QuestionChildren in back? Pin
Dov Sherman10-Jul-02 0:52
Dov Sherman10-Jul-02 0:52 
AnswerRe: Children in back? Pin
Rage10-Jul-02 5:41
professionalRage10-Jul-02 5:41 
GeneralRe: Children in back? Pin
Dov Sherman10-Jul-02 12:00
Dov Sherman10-Jul-02 12:00 
GeneralCombo Box showing Directories & Files Pin
Shibu.V.Nair10-Jul-02 0:12
Shibu.V.Nair10-Jul-02 0:12 
GeneralRe: Combo Box showing Directories & Files Pin
DanielP10-Jul-02 8:52
DanielP10-Jul-02 8:52 
GeneralGetting the back ground colour of a Dialog Pin
Shibu.V.Nair10-Jul-02 0:00
Shibu.V.Nair10-Jul-02 0:00 
GeneralRe: Getting the back ground colour of a Dialog Pin
Dov Sherman10-Jul-02 0:46
Dov Sherman10-Jul-02 0:46 
GeneralBeginner's Template question! Pin
Wayne Jin9-Jul-02 23:40
Wayne Jin9-Jul-02 23:40 
GeneralRe: Beginner's Template question! Pin
Terry Denham10-Jul-02 3:41
Terry Denham10-Jul-02 3:41 
GeneralRe: Beginner's Template question! Pin
Anonymous10-Jul-02 6:37
Anonymous10-Jul-02 6:37 
GeneralSetting the number of lines to scroll in Windows98 ... urgent....helppppp... Pin
Alek9-Jul-02 23:33
Alek9-Jul-02 23:33 
GeneralLoadBitmap in rectangle Pin
slah9-Jul-02 23:31
slah9-Jul-02 23:31 
GeneralRe: LoadBitmap in rectangle Pin
Dov Sherman10-Jul-02 0:45
Dov Sherman10-Jul-02 0:45 
GeneralWINAPI Book Pin
S van Leent9-Jul-02 22:48
S van Leent9-Jul-02 22:48 
GeneralRe: WINAPI Book Pin
slah9-Jul-02 23:35
slah9-Jul-02 23:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.