Thread: "Invisible" & sign.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    233

    "Invisible" & sign.

    I can't cut/paste because the machine with the IDE is not connected to the net!

    I place a label on the screen, and a button. When the button is pressed, it does:

    label1.Text = ">>>&<<<";

    What shows up on the screen is >>><<<. If I take the length of the .Text field it shows 7. If I write >>>&&<<< it appears right, (ie. a single ampersand), on the screen, but the length is now 8.

    Whats wrong here?
    Last edited by Fossaw; 03-12-2010 at 06:29 AM.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Use a verbatim string literal.

    Code:
    label1.Text = @">>>&<<<";
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    The &-char is used to indicate that the following char is used for keyboard shortcuts.

    "&Next" would spell "Next", once you press Alt, it would be "Next" and pressing "N" on the keyboard would select this action.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    233
    Still not present on the screen using the @ operator. It is in a string for example.
    Last edited by Fossaw; 03-12-2010 at 06:56 AM.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    I wasn't thinking and nvoigt set me straight.

    It wouldn't work. The problem is as nvoigt puts it. For the & sign to stop being treated as a special character, set the UseMnemonic property to false.

    Code:
    label1.UseMenmonic = false;
    label1.Text = ">>>&<<<";
    There's no need for a verbatim string either.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    233
    Yeah, that works. That's pretty gross isn't it.

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Not really. The API is free to establish the rules of how it operates. Since Mnemonics is such a fundamental aspect of a Windows GUI, it's perfectly acceptable. What would be gross was for the API to not give you the option to disable mnemonics on a control basis.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    233
    I don't want to get drawn into a debate here. I will say that I have googled, and searched the online documentation here for a couple of days and the solution was not apparent. The product is being pushed as a beginner tool, and beginners are not good at searching for stuff like this. The product is also making great pains to show it's xml features, where the & symbol is frequently used, (indeed, how I came upon the problem), yet I cannot find it there either.

    We disagree, fair enough.

  9. #9
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Quote Originally Posted by Fossaw View Post
    I don't want to get drawn into a debate here. I will say that I have googled, and searched the online documentation here for a couple of days and the solution was not apparent. The product is being pushed as a beginner tool, and beginners are not good at searching for stuff like this. The product is also making great pains to show it's xml features, where the & symbol is frequently used, (indeed, how I came upon the problem), yet I cannot find it there either.

    We disagree, fair enough.
    True, but think it the other way. If false for mnemonics was the default choice (you have to have a default choice). Then again you would need to search for it. And beginners wouldn't know the term mnemonics which would make searching for it more difficult to achieve the desired operation.
    So these kind of decisions from MS part are not easy. That is why they change things with every new release and there are always complains.
    My personal preference would be to keep it simple for beginners, thus agreeing with you. And enable options to change default parameters, so advance users wouldn't set Mnemonics always true with each label created. But then you have the marketing question. If you set everything simple by default, the new user might not learn its many features and never use them. Now you are encouraged to look upon the many options available.
    So, as expected, I would say that MS has the right policy, not meaning that they do everything right. Even thought I would want a different policy.

    The same goes for other API. I was using QT, for example, and I spent a lot of time trying to figure out how to set the background color of a control exactly the way I want. What it did was to inherit it from a parent control. So I disabled that feature. And again didn't work. I had to change an application variable, sth like an enviromental variable, to make it work the way I want. Impossible to find without searching the internet.

  10. #10
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Quote Originally Posted by C_ntua View Post
    True, but think it the other way. If false for mnemonics was the default choice (you have to have a default choice). Then again you would need to search for it. And beginners wouldn't know the term mnemonics which would make searching for it more difficult to achieve the desired operation.
    So these kind of decisions from MS part are not easy. That is why they change things with every new release and there are always complains.
    My personal preference would be to keep it simple for beginners, thus agreeing with you. And enable options to change default parameters, so advance users wouldn't set Mnemonics always true with each label created. But then you have the marketing question. If you set everything simple by default, the new user might not learn its many features and never use them. Now you are encouraged to look upon the many options available.
    Also, remember, this is a legacy feature. For the first versions of Windows, it WAS a very good idea to make everything use mnemonics by default, because the first versions were designed to be fully usable to users without a mouse -- which at the time was rare to see in the personal computing world.

    Even today, I'd say for most form elements it's desirable to use mnemonics, because people who will use your program regularly will often find the keyboard to be much faster than the mouse.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  11. #11
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Yes, we disagree. Although I'm not sure what product you are talking about.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #12
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    233
    MS Visual Studio 2008, Professional. C# more generally.
    Last edited by Fossaw; 03-12-2010 at 07:56 AM.

  13. #13
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Hmm... I don't know who told you this was for beginners. It's a programming language. Part of the apprenticeship process is exactly hunting down for answers to things we don't know. As we gather knowledge things start to fit in place and all will appear more easy and make more sense. It's not the other way around. In the beginning everything will appear confusing and difficult.

    That's what being a beginner is all about. Confused, bewildered and sometimes slightly annoyed.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  14. #14
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    233
    Microsoft have been presenting C# as the way forward to get many new people into development. If you browse the marketting bumph, (), it is full of stuff like that.

    The fact that I could not find it, (I have been a professional software engineer, i.e. in an office being paid for it, for 30+ years), indicates to me that it is not immediately apparent.

  15. #15
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    The & greatly predates C# for its use in mnemonics; it was part of the original WinAPI, and everything that's built upon the WinAPI, including Windows Forms, still recognizes it.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sign ' is the same as \' ?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 11-23-2007, 07:32 AM
  2. My own itoa()
    By maxorator in forum C++ Programming
    Replies: 18
    Last Post: 10-15-2006, 11:49 AM
  3. Handle on MSN Messenger's Sign In "button"?
    By jmd15 in forum Windows Programming
    Replies: 3
    Last Post: 07-16-2005, 09:28 PM
  4. How to detect change in sign?
    By bugsmashers in forum C++ Programming
    Replies: 16
    Last Post: 02-20-2005, 07:27 PM
  5. Sign Up!: The Third Round, both contests
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 54
    Last Post: 07-20-2002, 05:46 PM