CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2005
    Posts
    148

    Problem with CListCtrl::SetItem().

    Hai All,
    I have problem with list control.
    I inserted a list control in a dialog box.

    And I handled "NM_CLICK" in this dialog box class.

    In the same dialog class in some function I using SetItem as below:

    SetItem(0, 0, LVIF_TEXT, "Some Text", NULL, NULL, NULL, NULL);

    When I put a break point at the above statement, automatically I'm

    landing in "NM_CLICK" handler.

    I'm very much confused.
    I dont know why this happening.

    Please can be anybody explain me why this happening?

    Thanks...

  2. #2
    Join Date
    Mar 2005
    Location
    On the Dark Side of Moon
    Posts
    86

    Re: Problem with CListCtrl::SetItem().

    Have you inserted the List Items ??

    FRom MSDN :-

    CListCtrl::InsertItem
    int InsertItem( const LVITEM* pItem );

    int InsertItem( int nItem, LPCTSTR lpszItem );

    int InsertItem( int nItem, LPCTSTR lpszItem, int nImage );

    int InsertItem( UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam );

    Return Value

    The index of the new item if successful or -1 otherwise.

    Parameters

    pItem

    Pointer to anLVITEM structure that specifies the item’s attributes, as described in the Platform SDK.

    nItem

    Index of the item to be inserted.

    lpszItem

    Address of a string containing the item’s label, or LPSTR_TEXTCALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.

    nImage

    Index of the item’s image, or I_IMAGECALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.

    nMask

    The nMask parameter specifies which item attributes passed as parameters are valid. It can be one or more of the mask values described inLVITEM structure in the Platform SDK. The valid values can be combined with the bitwise OR operator.

    nState

    Indicates the item's state, state image, and overlay image. See the Platform SDK topics LVITEM for more information andList View Item States for a list of valid flags.

    nStateMask

    Indicates which bits of the state member will be retrieved or modified. See LVITEM in the Platform SDK for more information.

    nImage

    Index of the item’s image within the image list.

    lParam

    A 32-bit application-specific value associated with the item. If this parameter is specified, you must set the nMask attribute LVIF_PARAM.

    Remarks

    Inserts an item into the list view control.

    Example
    Code:
    // The pointer to my list view control.
    extern CListCtrl* pmyListCtrl;
    
    CString strText;
    int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount();
    
    // Insert 10 items in the list view control.
    for (int i=0;i < 10;i++)
    {
       strText.Format(TEXT("item %d"), i);
    
       // Insert the item, select every other item.
       pmyListCtrl->InsertItem(
          LVIF_TEXT|LVIF_STATE, i, strText, 
          (i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
          0, 0);
    
       // Initialize the text of the subitems.
       for (int j=1;j < nColumnCount;j++)
       {
          strText.Format(TEXT("sub-item %d %d"), i, j);
          pmyListCtrl->SetItemText(i, j, strText);
       }
    }

    Hope it helps you ...

    Thx

    x86

    Problem Is An Opportunity To Do Your Best.

    All Code Guru Member's
    Poll : -Please Vote For Code Guru Forum Programming competition


  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Problem with CListCtrl::SetItem().

    Quote Originally Posted by shinde
    When I put a break point at the above statement, automatically I'm

    landing in "NM_CLICK" handler.

    I'm very much confused.
    I dont know why this happening.
    Do you have a breakpoint in NM_CLICK's handler too?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Jan 2005
    Posts
    148

    Re: Problem with CListCtrl::SetItem().

    Hai x8086,
    Have you inserted the List Items ??
    Yes I did.

    Hai cilu,
    Do you have a breakpoint in NM_CLICK's handler too?
    No.

    I just kept a break point in the function where SetItem() is used.
    That's it.

    I tried with other application this problem does not happened.

    And I carefully rechecked my application and nowhere I found the problem.

    Does any time anybody experienced the similar situation ?

    Thanks....

  5. #5
    Join Date
    Apr 2003
    Location
    Athens, Greece
    Posts
    1,094

    Re: Problem with CListCtrl::SetItem().

    I just kept a break point in the function where SetItem() is used.
    That's it.
    Then what do you mean by "landing in NM_CLICK handler"?
    I think you need to post more code.
    Extreme situations require extreme measures

  6. #6
    Join Date
    Apr 2000
    Location
    Boston
    Posts
    124

    Re: Problem with CListCtrl::SetItem().

    Quote Originally Posted by shinde
    When I put a break point at the above statement, automatically I'm

    landing in "NM_CLICK" handler.
    Do you mean that when you debug, you expect the break to happen on that line of code but it looks like it is breaking in the NM_CLICK handler? If that is the case, have you done a clean or a rebuild all (the pdb file is not up to date)?

  7. #7
    Join Date
    Jan 2005
    Posts
    148

    Re: Problem with CListCtrl::SetItem().

    Hai panayotisk,
    actually I'm trying to solve it myself and with the help of forum, if not possible, I will do as you said.

    Hai Mike200,
    may be you are right. I will try it now...
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured