ListView SetCheck

This is a discussion on ListView SetCheck within the Windows Programming forums, part of the Platform Specific Boards category; How do you I set the check mark checked with the SendMessage? I saw on a previous board that there ...

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

    ListView SetCheck

    How do you I set the check mark checked with the SendMessage? I saw on a previous board that there is ListView_SetCheckState, but I searched the <commctrl.h> and it didn't find that macro.

    I got this so far:
    Code:
    void SetItemChecked(HWND hwnd, int index)
    {
       LVITEM lvItem;
    
       lvItem.mask=LVIF_STATE;
       // lvItem.state= //stuck here
    
       SendMessage(hwnd, LVM_SETITEMSTATE, (WPARAM) (int)index, (LPARAM) (LPLVITEM)lvItem);
    }

    The constants I found were:
    LVIS_ACTIVATING
    The item is being activated in an LVN_ITEMACTIVATE notification.

    LVIS_CUT
    The item is marked for a cut-and-paste operation.

    LVIS_DROPHILITED
    The item is highlighted as a drag-and-drop target.

    LVIS_FOCUSED
    The item has the focus, so it is surrounded by a standard focus rectangle. Although more than one item may be selected, only one item can have the focus.

    LVIS_SELECTED

    The item is selected. The appearance of a selected item depends on whether it has the focus and also on the system colors used for selection.


    I don't know what constant to enter here. Or if I have to fill out more fields. Any help would be really be appriated.

    Thanks.

  2. #2
    rHm
    rHm is offline
    Registered User
    Join Date
    Jul 2004
    Posts
    4
    The easiest way is to use the ListView_SetCheckState macro documented at msdn:
    ListView_SetCheckState

    For such problems you should first search at msdn - mostly you find the answer fast.

    Greetz
    Andy

  3. #3
    Registered User KonArtis's Avatar
    Join Date
    Mar 2003
    Posts
    34
    I would use ListView_SetCheck but when I do, the compiler says that it doesn't exist. So I went to commctrl.h so search for it, but it didn't find it. Thats why I wanted another way of setting the check.

    Thanks.

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

    Talking

    I figured it out...finially

    Code:
    void SetItemChecked(HWND hwnd, int index)
    {
       LVITEM lvItem;
    
       lvItem.stateMask=LVIS_STATEIMAGEMASK;
       lvItem.state=INDEXTOSTATEIMAGEMASK(2);
    
       SendMessage(this->hwnd, LVM_SETITEMSTATE, index, (LPARAM)&lvItem);
    }
    lvItem.state=INDEXTOSTATEIMAGEMASK(2);
    2 means the box will be checked
    1 means the box will be unchekced
    0 means there won't be a box

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ListView Refresh, Update
    By de4th in forum C++ Programming
    Replies: 1
    Last Post: 12-23-2006, 08:13 AM
  2. Replies: 6
    Last Post: 07-10-2006, 12:05 AM
  3. Troubles with ListView and Toolbar
    By cornholio in forum Windows Programming
    Replies: 8
    Last Post: 11-14-2005, 12:26 AM
  4. Listview with c/c++
    By X PaYnE X in forum Windows Programming
    Replies: 8
    Last Post: 03-20-2005, 10:29 PM
  5. Listview??
    By SuperNewbie in forum C# Programming
    Replies: 4
    Last Post: 02-13-2003, 02:34 AM

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