CListCtrl limit 260 characters?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Thread: CListCtrl limit 260 characters?

  1. #1
    Join Date
    May 2002
    Posts
    109

    CListCtrl limit 260 characters?

    I have a CListCtrl and for some reason, if I type in more than 260
    characters in a cell, it just acts really wierd. It starts shifting data
    and just seems to cut off that cell at 259 characters. Any idea on
    how to expand the number of characters a subitem in a CListCtrl
    can hold?

    Please, any response any one can give me will be greatly
    appreciated.

    Sincerely,
    Danielle Brina (an overworked graduate student)

  2. #2
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Wink Re: CListCtrl limit 260 characters?

    Quote Originally Posted by DanYELL
    I have a CListCtrl and for some reason, if I type in more than 260
    characters in a cell, it just acts really wierd. It starts shifting data
    and just seems to cut off that cell at 259 characters. Any idea on
    how to expand the number of characters a subitem in a CListCtrl
    can hold?

    Please, any response any one can give me will be greatly
    appreciated.

    Sincerely,
    Danielle Brina (an overworked graduate student)
    Frankly, I don't know CListCtrl - but, it does not make sense that the Control Limits string input length.


    However, your observation that the number of characters supported are -
    259 + 1 NULL CHAR = 260
    seems ominous of a Character Array initialized to MAX_PATH or an equivalent.
    Code:
    #define MAX_PATH 260
    And perhaps, your character buffer is something like this -
    Code:
     char strMyListBuf [MAX_PATH];
    Please check this up! You must use a dynamically allocated buffer and not a statically allocated one!
    Last edited by Siddhartha; April 4th, 2005 at 12:25 PM.

  3. #3
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: CListCtrl limit 260 characters?

    Quote Originally Posted by DanYELL
    I have a CListCtrl and for some reason, if I type in more than 260
    characters in a cell, it just acts really wierd. It starts shifting data
    and just seems to cut off that cell at 259 characters. Any idea on
    how to expand the number of characters a subitem in a CListCtrl
    can hold?
    The default text limit is 260 chars for the labels of a listview control. To change that, call SetLimitText() for the label's edit control when processing the LVN_BEGINLABELEDIT message:
    Code:
    void CTestDlg::OnBeginlabeleditListTest(NMHDR* pNMHDR, LRESULT* pResult) 
    {
      LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
    
      CEdit* pEdit = m_listTest.GetEditControl();
      ASSERT(pEdit);
      pEdit->LimitText(1024); // Set the new limit to 1024 chars
      *pResult = 0;
    }

  4. #4
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Wink Re: CListCtrl limit 260 characters?

    Quote Originally Posted by gstercken
    The default text limit is 260 chars for the labels of a listview control. To change that, call SetLimitText() for the label's edit control when processing the LVN_BEGINLABELEDIT message
    I have made a faux-pas in my post above.

    Thanks for pointing it out!

  5. #5
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: CListCtrl limit 260 characters?

    Quote Originally Posted by Siddhartha
    I have made a faux-pas in my post above.
    Thanks for pointing it out!
    No problem...

  6. #6
    Join Date
    Jul 2005
    Posts
    4

    Unhappy Re: CListCtrl limit 260 characters?

    I need your help regarding ClistCtrl and it has to do with the length of columns…

    When creating a CListCtrl even though I set cchTextMax to for example 2000, when the method that handles the LVN_GETDISPINFO is called, the cchTextMax is always set to 260.

    Even if I set a new buffer to pszText and set cchTextMax to 2000, when displaying the column the data presented is truncated to 260.

    How to display a column with length bigger than the default of 260 characters?

    Thank you for all your help!
    magda.

  7. #7
    Join Date
    Jul 2003
    Posts
    731

    Re: CListCtrl limit 260 characters?

    Use LPSTR_TEXTCALLBACK to associate item text this will use your buffer to hold text and it should fix it. I have never seen the 256 limit for myself though or I am unaware of.
    Good Answers, Good Points.

  8. #8
    Join Date
    Jul 2005
    Posts
    4

    Re: CListCtrl limit 260 characters?

    Thank you for your reply!

    I am using LPSTR_TEXTCALLBACK when creating my list, and in the method that handles the LVN_GETDISPINFO, I am doing the following:
    void CListCtlTestDlg::OnGetdispinfoList1(NMHDR* pNMHDR, LRESULT* pResult)
    {
    LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
    if (pDispInfo->item.mask & LVIF_TEXT)
    {
    :

    :

    :

    char cChar[2048];
    memset(cChar, '\0', 2000);
    pDispInfo->item.pszText = &cChar[0];
    pDispInfo->item.cchTextMax = 2048;
    lstrcpyn(pDispInfo->item.pszText, csAux, (csAux.GetLength()+1));
    }
    :
    :
    *pResult = 0;
    }

    but the data is still being presented truncated at 260 characters.

    magda.

  9. #9
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,437

    Re: CListCtrl limit 260 characters?

    If this is your exact code, the character buffer is going out of scope.

    Arjay

  10. #10
    Join Date
    Jul 2005
    Posts
    4

    Re: CListCtrl limit 260 characters?

    Hi,

    the buffer i am moving to cChar comes from a CString namdecsAux that cotains a text that is no bigger than 2000 characters...so, it seems the cChar is not going out of scope....

    I am confused...
    magda.

  11. #11
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: CListCtrl limit 260 characters?

    Quote Originally Posted by wurzlmagda
    the buffer i am moving to cChar comes from a CString namdecsAux that cotains a text that is no bigger than 2000 characters...so, it seems the cChar is not going out of scope....
    Yes, it goes out of scope (when the block ends). You assign the address of the first character of cChar to pDispInfo->item.pszText (note that you could just as well write pDispInfo->pszText = cChar).
    Then you copy the contents of csAux to the cChar buffer - why are you passing csAux.GetLength()+1 as the length, BTW?
    After that, cChar goes out of scope, and pDispInfo->pszText points to a variable that no longer exists.

  12. #12
    Join Date
    Jul 2005
    Posts
    4

    Unhappy Re: CListCtrl limit 260 characters?

    even by solving the out of scope, the data presented is still limited to 260 even though cchTextMax is being set to 2048…

    can you help me with the 260 limit???

    Thank you for all your replies,
    magda.

  13. #13
    Join Date
    Mar 2002
    Location
    Germany
    Posts
    63

    Re: CListCtrl limit 260 characters?

    Does this apply to your question ?

    MSDN - bug report

  14. #14
    Join Date
    May 2014
    Posts
    4

    Re: CListCtrl limit 260 characters?

    You may use the Long Path Tool to overcome this problem. I'm sure it will help.

  15. #15
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,524

    Re: CListCtrl limit 260 characters?

    Quote Originally Posted by adamenko View Post
    You may use the Long Path Tool to overcome this problem. I'm sure it will help.
    I have no idea what "the Long Path Tool" is and how could it help the OP.
    What I know exactly is one has to read the docs (MSDN) and implement bug-free code to not have the problems like OP had.
    I use since a years list view controls with the item text lengths much more than standard MAX_PATH (260) symbols. Without any problem.
    And I believe that both OP and wurzlmagda already had fixed their bugs (it was about 9 years back!) since this thread was sleeping all this time!
    Victor Nijegorodov

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center