CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2008
    Posts
    13

    Truncation Issue with LVIF_TEXT

    Hi,

    I am using a CListCtrl object and setting the items in it. Every item in the list is an LVITEM. The mask on one of the sub items is LVIF_TEXT.

    LVITEM
    lvItem.mask = LVIF_TEXT;
    lvItem.pszText = "&&&&"

    the pszText is "&&&&" ( 4 & symbols). However, there seems to be a truncation issue when this list is displayed and only "&&" ( 2 & are displayed).

    Could you help me in figuring out why this is happening? Is there a known bug in LVIF_TEXT where it truncates symbols other than alphabets and numbers??

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Truncation Issue with LVIF_TEXT

    It is NOT a bug. It is by design.
    An ampersand (&) has a specific meaning in Windows. From MSDN:
    An ampersand (&) character in the text indicates that the following character is used as a mnemonic character for the control. When the control is displayed, the ampersand is not shown, but the mnemonic character is underlined. The user can choose the control by pressing the key corresponding to the underlined mnemonic character. To use the ampersand as a character in a string, insert two ampersands (&&).
    Last edited by VictorN; October 8th, 2008 at 05:06 AM.
    Victor Nijegorodov

  3. #3
    Join Date
    Sep 2008
    Posts
    13

    Smile Re: Truncation Issue with LVIF_TEXT

    Hey Victor,
    Thanks for the help....

  4. #4
    Join Date
    Sep 2008
    Posts
    13

    Re: Truncation Issue with LVIF_TEXT

    can I use some other mask instead of the LVIF_TEXT mask.....

    since, in the List Ctrl I am displaying a subject and I dont want user text to be truncated .....

    for example if the user's subject is

    Mode of communication is Mail & email, it would display as MailEMail with an underscore below e.
    this might lead to a confusion to the user.......

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Truncation Issue with LVIF_TEXT

    Just replace an ampersand (&) character with two ampersands (&&) before setting the item/subitem text..
    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
  •  





Click Here to Expand Forum to Full Width

Featured