ListView Control

This is a discussion on ListView Control within the Windows Programming forums, part of the Platform Specific Boards category; I was using ListView_GetCheckState to see if an item is checked, but there isn't a ListView_SetCheckState and I can't seem ...

  1. #1
    Registered User KonArtis's Avatar
    Join Date
    Mar 2003
    Posts
    34

    ListView Control

    I was using ListView_GetCheckState to see if an item is checked, but there isn't a ListView_SetCheckState and I can't seem to find any other message to do it. Do anyone know if there is a message to set the check mark checked without user input?

    Thanks

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    9
    Quote Originally Posted by KonArtis
    but there isn't a ListView_SetCheckState
    Actually there is, and it works fine for me:
    http://msdn.microsoft.com/library/de...checkstate.asp
    You can also send LVM_SETITEMSTATE with the right LVITEM struct values to do the same thing.

  3. #3
    Registered User KonArtis's Avatar
    Join Date
    Mar 2003
    Posts
    34
    I tried the ListView_SetCheckState macro but it gives me an error. And for the LVM_SETITEMSTATE message, I'm not sure how to set the check state in the LVITEM struct. Could be a little more detailed?

    Thanks.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    ListView_SetItemState may also be of some interest.

    >>but it gives me an error<<

    Help us to help you by telling us what the error is.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User KonArtis's Avatar
    Join Date
    Mar 2003
    Posts
    34
    The error for ListView_SetCheckState is that is doesn't exist.

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Have you #defined _WIN32_IE? Check out your commctrl.h header file for details of ListView_SetCheckState use; I think it just calls ListView_SetItemState anyway.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  7. #7
    Registered User KonArtis's Avatar
    Join Date
    Mar 2003
    Posts
    34
    If I use ListView_SetItemState, I'm not sure what to set with the LVITEM object. Can you help?

    Thanks.

  8. #8
    Registered User
    Join Date
    Mar 2004
    Posts
    9
    This is what ListView_SetCheckState is defined as in WIN.H here:
    Code:
    #define ListView_SetCheckState(h,i,f) ListView_SetItemState(h,i,INDEXTOSTATEIMAGEMASK((f)?2:1),LVIS_STATEIMAGEMASK)
    You could try adding that to win.h or just using SetItemState yourself, replacing h, i and f.
    h = ListView Handle
    i = Item Number
    f = True/False

  9. #9
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    win.h is specific to lcc-win32 and I suspect the OP may be using a not too up to date version of mingw, specifically commctrl.h.

    But SnarlingSheep's advice is good: you can see from the macro definition the required parameters. For an explanation of where the '1' and '2' come from read the comments for LVS_EX_CHECKBOXES and the remarks under ListView_SetItemState.

    For completeness:
    Code:
    ListView_SetItemState(hListview, index, INDEXTOSTATEIMAGEMASK(1), LVIS_STATEIMAGEMASK); /*unchecked */
    ListView_SetItemState(hListview, index, INDEXTOSTATEIMAGEMASK(2), LVIS_STATEIMAGEMASK); /*checked */
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with ListView Control
    By elaverick in forum C# Programming
    Replies: 8
    Last Post: 04-29-2008, 03:42 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  3. A few questions on ListView Control...
    By Devil Panther in forum Windows Programming
    Replies: 0
    Last Post: 09-05-2003, 02:33 PM
  4. Edit control on listview
    By knutso in forum Windows Programming
    Replies: 5
    Last Post: 08-10-2003, 09:11 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21