• The Old New Thing

    When do you disable an option and when do you remove it?


    When you're displaying a menu item or a dialog option, and the option is not available, you can either disable it or you can remove it. What is the rule for deciding which one to do?

    Experiments have shown that if something is shown but disabled, users expect that they will be able to get it enabled if they tinker around enough.

    So leave a menu item shown but disabled if there is something the user can do to cause the operation to become available. For example, in a media playback program, the option to stop playback is disabled if the media file is not playing. But once it starts playing, the option becomes available again.

    On the other hand, if the option is not available for a reason the user has no control over, then remove it. Otherwise the user will go nuts looking for the magic way to enable it. For example, if a printer is not capable of printing color, don't show any of the color management options, since there's nothing the user can do with your program to make that printer a color printer.

    By analogy, consider a text adventure game. The player tries something clever like "Take the torch from the wall", and the computer replies, "You can't do that, yet." This is the adventure game equivalent to graying out a menu item. The user is now going to go nuts trying to figure out "Hm, maybe I need a chair, or the torch is too hot, or I'm carrying too much stuff, or I have to find another character and ask him to do it for me..."

    If it turns out that the torch is simply not removable, what you've done is send the user down fruitless paths to accomplish something that simply can't be done. For an adventure game, this frustration is part of the fun. But for a computer program, frustration is not something people tend to enjoy.

    Note that this isn't a hard-and-fast rule; it's just a guideline. Other considerations might override this principle. For example, you may believe that a consistent menu structure is more desireable because it is less confusing. (A media playback program for example might decide to leave the video-related options visible but grayed when playing a music file.)

  • The Old New Thing

    Thinking through a feature


    The commentary after my entry on taskbar grouping drifted into people asking for still more features in taskbar grouping.

    Writing the code is the easy part.

    Designing a feature is hard.

    You have several audiences to consider. It's not just about the alpha geeks; you have to worry about the grandmothers, the office workers, the IT departments. They all have different needs. Sometimes a feature that pleases one group offends another.

    So let's look at some of the issues surrounding the proposed feature of allowing users to selectively ungroup items in the taskbar.

    One issue with selective grouping is deciding the scope of the feature. Suppose the user ungroups Internet Explorer, then closes all the IE windows, then opens two new IE windows: Do the new ones group?

    If so, then you now have an invisible setting. How do you configure grouping for programs that aren't running? (How do you configure something that you can't see?)

    Suppose you've figured that out. That's fine for the alpha geeks, but what about grandma?

    "The Internet is all disorganized."

    "What do you mean?"

    "All my Internet windows are all disorganized."

    "Can you explain a little more?"

    "My taskbar used to be nice and organized, but now the Internet parts are disorganized and spread out all over the place. It used to be nice and neat. I don't know how it happened. I hate the Internet, it's always messing up my computer."

    What is the UI for selective ungrouping? Anything that is on a context menu will be executed accidentally by tens of thousands of people due to mouse twitching. Putting the regroup onto the context menu isn't necessarily good enough because those people don't even realize it was a context menu that did it. It was just a mouse twitch.

    Mouse twitches cause all sorts of problems. Some people accidentally dock their taskbar vertically; others accidentally resize their taskbar to half the size of the screen. Do not underestimate the havoc that can be caused by mouse twitching.

    Soon people will want to do arbitrary grouping. "I want to group this command prompt, that notepad window, and this calc window together."

    What about selective ungrouping? "I have this group of 10 windows, but I want to ungroup just 2 of them, leaving the other 8 grouped together."

    Once you have selective/arbitrary grouping, how do you handle new windows? What group do they go into?

    Remember: Once you decide, "No, that's too much," there will be thousands of people cursing you for not doing enough. Where do you draw the line? And also remember that each feature you add will cost you another feature somewhere else. Manpower isn't free.

    But wait, the job has just begin. Next, you get to sit down and do the usability testing.

    Soon you'll discover that everything you assumed to be true is completely wrong, and you have to go back to the drawing board. Eventually, you might conclude that you over-designed the feature and you should go back to the simple on/off switch.

    Wait, you're still not done. Now you have to bounce this feature off corporate IT managers. They will probably tear it to shreds too. In particular, they're going to demand things like remote administration and the ability to force the setting on or off across their entire company from a central location. (And woe unto you if you chose something more complicated than an on/off switch: Now you have to be able to deploy that complex setting across tens of thousands of computers - some of which may be connected to the corporate network via slow modems!)

    Those are just some of the issues involved in designing a feature. Sometimes I think it's a miracle that features happen at all!

    (Disclaimer: I'm not saying this is how the grouping feature actually came to be. I just used it as a starting point for a rant.)

    For another perspective, you can check out KC Lemson's discussion of the feature-design process a few days ago under the topic There's no such thing as a simple feature.

  • The Old New Thing

    Norway: Pros and cons


    For the third year in a row, the United Nations' Development Program has ranked Norway as having the best standard of living in the world. Norwegians beat out all others because of their high levels of education, pay and life expectancy.

    In a totally unrelated story: Norway world leader in casual sex.

    Of course, Norway isn't all candy canes and lollipops. You also have to worry about cow attacks and cows falling from the sky.

    Cows rampage in Norway

    In a bizarre series of incidents, two farmers in different parts of the country were hospitalized after being attacked by cows. Elsewhere, four men narrowly missed having their car crushed by a crash-landing cow.

  • The Old New Thing

    Is your web site an open relay?


    As if there isn't enough to worry about.

    Everyone knows about the dangers of open SMTP relays. But how many people realize the dangers of an open HTTP relay?

    Many web sites do arbitrary redirection. If I were a spammer, I could create a link to myself that redirects through some well-known web sites, thereby granting my spam link false authenticity.


    With some obfuscatory work, I can make my own URL disappear completely, leaving just yours.


    What does this mean for you, the redirector?

    • It creates additional load on your server.
    • It makes Bayesian filters think that your site is spam, since your site's name appears in spam URLs. This can cause problems if you intend to send legitimate mail to your customers.
    • It can fool people into thinking that your site is the source of the spam.

    The two examples I gave above are the big guys who are being attacked by spammers on all sides. In fact, their names are co-opted by spammers so much that some spam redirection URLs probably don't affect their Bayesian rating significantly. But if you're a small site that also has unchecked redirection, you may want to take a closer look.

  • The Old New Thing

    Varför läser jag svenska?


    (Even if you don't read Swedish, you may enjoy the links at the end.)

    Några personer har frågat mig varför jag läser svenska.

    Historien börjar för många år sedan. Jag läste tidningen och såg att det fanns avgiftsfria norskalektioner i Ballard kyrkans källaren. (Ballard är en del av Seattle där många människor som kommer från Norden bor. Den mesta är norska.) Jag tänkte mig att det skulle vara roligt om jag gick till klassen. Jag skulle säkert vara den enda personen som inte var tvungen att läsa norska av sina föreldrar.

    Men jag gjorde inte det.

    Ett par år senare tillkom de olympiska spelen i Lillehammer, och när jag hörde det norska språket, tyckte jag att det lät skönt och att jag skulle börja läsa norska.

    Men jag gjorde inte det.

    I förra året flyttade min vän till Uppsala för att studera på universitet som utbytesstudent. Jaha, nu måsta jag lära mig svenska för att besöka honom! Men innan min första klass sa hans bror till mig, "Jag har ett arbetsmöte i Mnchen nästa vecka. Vill du komma med? Vi kan besöka Jonathan i Uppsala." Det var min nödssemester.

    Jag hade redan betalat för den svenska kursen, så jag gick till klasserna i alla fall. Sex månader senare reste jag till Sverige igen.

    Nu har jag inga bestämda planer på att resa dit en gång till, och jag kommer nog att ta en paus från att läsa svenska i utgången av sommar, så att jag kan börja att läsa kineska. (Jag tror att kineska kommer att vara svårare än svenska...)

    Om jag hade sökt på Internetet skulle jag ha funnit andra skäl. En Google-sökning avslöjar att "When you win the Nobel Prize, you can give your acceptance speech in Swedish!" Men de glömde att ange att det inte gäller om du vinner Nobelfredspriset. I så fall har du ödslat tid på det felaktiga språket! (Det upptäckte jag i förra året när jag bestämde mig för att vara Nobelfredspriset på allhelgonaafton...)

    (Ett annat skäl: Svenska finns inte på Babelfish.)

    Jag tycker att det är intressant att en Google-sökning efter "Why study Swedish?" hittar bara 12 webbsidor. Jämför "Why study French?", som finns på 700 webbsidor, ungefär den samma mängden som engelska.

    Förresten, "Why study at all?" finns på 20 webbsidor. Undrar du ännu varför inte många människor läser svenska?

  • The Old New Thing

    How do the FILE_SHARE_* bits interact with the desired access bits?


    It's really not that complicated. If you permit, say, FILE_SHARE_READ, then you're saying, "I'm okay with other people reading this file while I have it open." And if you leave off the flag, then you're saying, "I do not want other people reading this file while I have it open."

    Now all that's left to do is work out what that means.

    So suppose you omit the flag, indicating that you don't want to let others read the file. Then when you attempt to open it yourself, the open will fail if anybody else has the file open for reading. And if the open succeeds, then the system will prevent anybody else from opening the file for reading until you close your handle.

    That's all.

    Of course, if the file is already open, then a corresponding check is made between your desired access and the file sharing mode of the people who already opened it. For example, if somebody already has the file open and denies read sharing, then if you try to open for read, you will get a sharing violation.

    These restrictions are cumulative, of course. If one person opens a file without FILE_SHARE_READ and another person opens a file without FILE_SHARE_WRITE, then attempts to open the file for read or for write will fail. (The read fails because the first person didn't permit read, and the write fails because the second person didn't permit write.)

    Repeat the above logic for "delete" and "write" permission, and that's it in a nutshell.

    There is a big nasty table in MSDN that walks through all the combinations, but I personally think it confuses the matter rather than clarifying.

    Even more confusingly, the table uses "X" to mean that the combination is permitted. They should've used a bullet ("•") or a check mark ("ü"), since an "X" has the connotation of "not allowed".

    Let's look at one row of the table and see how the information in it is "obvious": Say, the row that reads "GENERIC_READ / GENERIC_WRITE / FILE_SHARE_READ". You are asking for read and write, and you permit read (and implicitly deny write).

    The requested access (read/write) requires that all previous openers have granted both read and write. There are three columns that correspond to this, namely the ones that say "FS_R FS_W".

    The requested sharing mode (read only) requires that all previous openers have requested read-only access. In other words, there can't be any G_W entries. That rules out two of the columns, leaving just "G_R FS_R FS_W", and indeed only one column is checked in the table.

    Notice that the file share bits you pass don't have to match up with your file access bits. The file share bits indicate what you want to allow other people to do. The access bits indicate what you want to do yourself.

  • The Old New Thing

    Links about COM threading models


    There have been a few good articles about threading models, one from Eric Lippert and another from Larry Osterman. Go off and read them if you haven't already.

  • The Old New Thing

    There are two types of scrollbars


    Remember that there are two types of scrollbars.

    One is the standalone scrollbar control. This one has its own window handle, and consequently can be given focus and all those other fun things you can do with window handles. To manipulate them, pass the handle to the scrollbar control to the appropriate scrollbar function (SetScrollInfo, for example) and pass SB_CTL as the nBar parameter to indicate that you have a scrollbar control.

    The other type is the horizontal or vertical scrollbar (or both) attached to a window by virtue of having the WS_HSCROLL and/or WS_VSCROLL style. These are nonclient scrollbars and are not controls. They are just decorations added to some other window. You can't give them focus since they aren't windows in their own right. To manipulate them, pass the handle to the containing window to the appropriate scrollbar function and pass SB_HORZ or SB_VERT as the nBar parameter to indicate that you want to manipulate the nonclient horizontal or vertical scrollbar.

    I'm writing this down since some people seem to miss the distinction between these two cases.

  • The Old New Thing

    A guide to British pub etiquette


    Social researchers dissect the interactions and unveil the unwritten rules that govern British pub etiquette.

  • The Old New Thing

    Image File Execution Options


    Hereby incorporating by reference Junfeng Zhang's discussion of the Image File Execution Options registry key.

Page 393 of 430 (4,292 items) «391392393394395»