SetWindowText is not removing & charatcter in a string.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: SetWindowText is not removing & charatcter in a string.

  1. #1
    Join Date
    Jan 2007
    Posts
    142

    Smile SetWindowText is removing & charatcter in a string.

    Hi,
    Im passing "& temp1 & temp2" string as a parameter to SetWindowText("& temp1 & temp2"). not sure why it sets the text as temp1 temp2. & character is getting removed.
    Last edited by resumurof; July 4th, 2012 at 05:03 AM.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,424

    Re: SetWindowText is removing & charatcter in a string.

    Quote Originally Posted by resumurof View Post
    Hi,
    Im passing "& temp1 & temp2" string as a parameter to SetWindowText("& temp1 & temp2"). not sure why it sets the text as temp1 temp2. & character is getting removed.
    That is because for certain classes of windows, the '&' denotes that the next letter is the "shortcut" letter (the letter that is underlined in a button, for example).

    So as an example, if the window was a button, using SetWindowText("C&ancel") will have the 'a' underlined, which means that the 'a' is the hotkey/shortcut. To actually place an ampersand as text, you use two successive ampersands.
    Code:
    SetWindowText("&& temp1 && temp2");
    Regards,

    Paul McKenzie

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center