• The Old New Thing

    What is the difference between Minimize All and Show Desktop?


    The keyboard shortcut for "Minimize All" is ÿ+M and The keyboard shortcut for "Show Desktop" is ÿ+D. How are they different?

    "Minimize All" is easier to describe. It minimizes all the windows that support the "Minimize" command. You can minimize a window by selecting "Minimize" from its System menu, or by clicking the 0 button in the title bar. So "Minimize All" is effectively the same as going to each window that is open and clicking the Minimize button. If there is a window that doesn't have a Minimize button, then it is left alone.

    "Show Desktop" takes "Minimize All" one step further. After minimizing all the windows that can be minimized, it then takes the desktop and "raises" it to the top of the window stack so that no other windows cover it. (Well, okay, topmost windows continue to cover it.)

    So "Show Desktop" manages to get a few more windows out of your way than "Minimize All".

    Note, however, that when you return the desktop to its normal state (either by selecting "Show Open Windows" or just by switching to another window), all the un-minimizeable windows come back because the desktop has "lowered" itself back to the bottom of the window stack.

  • The Old New Thing

    Meet Anton Chekhov


    (Not to be confused with Star Trek's Pavel Chekov, who spells his name with a plain "k" instead of a "kh". Of course, since this is all transliteration from Cyrillic, of which there are multiple systems, arguing about spelling is rather dubious anyway.)

    The guerilla performance group Improv Everywhere stages events in public places and carefully records the reaction of their unwitting "audience". Perhaps one of their best-known stunts is the appearance of author Anton Chekhov at a New York City Barnes and Noble.

    After the reading, they set up a table in Union Square Park across the street and sold autographed copies of The Cherry Orchard from a table.

    The young man in the jean jacket above insisted that Chekov only sign his autograph, rather than making it out to anyone in particular. He proudly announced, "When you die, this is going to be worth lots of money!"

    Though I think their best performance from an artistic performance point of view was The Moebius.

  • The Old New Thing

    How does the desktop choose the icon label color?


    Many system colors come in pairs, one for background and one for foreground. For example, COLOR_MENU and COLOR_MENUTEXT; COLOR_WINDOW and COLOR_WINDOWTEXT; COLOR_HIGHLIGHT and COLOR_HIGHLIGHTTEXT. More on these colors in a future blog entry.


    How does the desktop choose the icon label color?

    It's not very exciting.

    The COLOR_DESKTOP color is studied to see if it is mostly dark or mostly light. If mostly dark, then the icon text is white. If mostly light, then the icon text is black.

    This works great if you don't have a wallpaper. If you do, then the desktop color doesn't typically correspond to the dominant color in your wallpaper, which may lead to a poor choice of black vs. white.

    To remedy this, you can manually set the desktop color by going to the Display control panel and going to the Desktop tab. Change the desktop color to something dark to get white icon text and to something light to get black icon text.

  • The Old New Thing

    Art too bad to be ignored


    The Museum of Bad Art: Art Too Bad To Be Ignored.

    The Athlete
    Crayon and pencil on canvas by Unknown
    Acquired from trash in Boston by Scott Wilson

    A startling work, and one of the largest crayon on canvas pieces that most people can ever hope to see. The bulging leg muscles, the black shoes, the white socks, the pink toga, all help to make this one of the most popular pieces in the MOBA collection.

    The Athlete also happens to be one of the most controversial works in the MOBA collection. Read the scandalous details!

  • The Old New Thing

    When you change the insides, nobody notices


    I find it ironic when people complain that Calc and Notepad haven't changed. In fact, both programs have changed. (Notepad gained some additional menu and status bar options. Calc got a severe workover.)

    I wouldn't be surprised if these are the same people who complain, "Why does Microsoft spend all its effort on making Windows 'look cool'? They should spend all their efforts on making technical improvements and just stop making visual improvements."

    And with Calc, that's exactly what happened: Massive technical improvements. No visual improvement. And nobody noticed. In fact, the complaints just keep coming. "Look at Calc, same as it always was."

    The innards of Calc - the arithmetic engine - was completely thrown away and rewritten from scratch. The standard IEEE floating point library was replaced with an arbitrary-precision arithmetic library. This was done after people kept writing ha-ha articles about how Calc couldn't do decimal arithmetic correctly, that for example computing 10.21 - 10.2 resulted in 0.0100000000000016.

    (These all came from people who didn't understand how computers handle floating point. I have a future entry planned to go into floating point representations in more detail.)

    Today, Calc's internal computations are done with infinite precision for basic operations (addition, subtraction, multiplication, division) and 32 digits of precision for advanced operations (square root, transcendental operators).

    Try it: 1 / 3 * 10000000000 - 3333333333 =. The result is one third exactly. Type 1/x - 3 = and you get zero back. (Of course, if you don't believe that, then repeat the sequence "* 10000000000 - 3333333333 =" until you're bored and notice that the answer always comes back as 0.33333333333333333333333333333333. If it were fixed-precision, then the 3's would eventually stop coming.)

    Thirty-two positions of precision for inexact results not good enough? The Power Calculator PowerToy uses the same arithmetic engine as Calc and lets you crank the precision to an unimaginable 512 digits.

    Anyway, my point is that - whether you like it or not - if you don't change the UI, nobody notices. That's so much effort is spent on new UI.

  • The Old New Thing

    The F*deral Bur*au of Inv*stigations


    According to the Chicago Division,

    Use of the NAME, INITIALS, or SEAL of the F*I
    is restricted by law
    and may be used only with written permission of the F*I.

    Asterisks inserted to avoid being arrested by the F*I for using their name and initials without written permission.

    (I hope they don't go after me for using their initials without permission late last year.)

  • The Old New Thing

    Extending the Internet Explorer context menu


    In a comment, Darrell Norton asked for a "View in Mozilla" option for Internet Explorer.

    You can already do this.

    Internet Explorer's context menu extension mechanism has been in MSDN for years. Let me show you how you can create this extension yourself.

    First, create the following registry key:

    [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\View in Mozilla]

    Of course, you need to change C:\some\path\to to an actual path.

    How did I know to do this? Because steps 1, 2 and 3 in the "Implementation Steps" section tell me (1) what key to create, (2) what to set the default value to, and (3) what to set Contexts to. I chose a Context value of 1, which means "Default".

    Okay, now to write the script ViewInMozilla.htm. Well, the documentation says that I can access context from the menuArguments property of the external object. So let's start with that.


    Okay, let's run this puppy. Launch IE, right-click on a blank space in the web page, select "View in Mozilla", and you get...


    Woo-hoo! This is a major accomplishment: Something happened at all. Doing things in small steps makes it easy to identify where a problem is. If we had run full steam ahead to completion and then it didn't work, we wouldn't have known whether it was due to a bug in the script, a bad registration, a bad filename...

    Now that I have the menu arguments, I can use that to suck out information about the item that the context menu applies to. Let's try this:


    Woo-hoo, now it gives me the URL. Almost there. All that's left to do is to run a program with that URL as the command line parameter.

    var shell = new ActiveXObject("WScript.Shell");
    shell.run("mozilla \"" + external.menuArguments.document.URL + "\"");

    Mission accomplished.

    Now you too can create Internet Explorer context menu extensions.

    In fact, go ahead and do it, since Darrell asked for it: Create an Internet Explorer context menu extension that operates on anchors and opens the linked-to page in Mozilla.

    (Bonus: Tony Schreiner cooked up something similar for zooming.)

  • The Old New Thing

    Callback, the safety newsletter for the aviation community


    Yes the "S" in NASA stands for "Space", but don't forget that the "A" stands for "Aeronautics". One of the programs that I (amateur aviation wannabe) find fascinating is the Aviation Safety Reporting System, where pilots can submit anonymous reports of "stupid things I have done" in order to teach other pilots "Don't do what I did."

    Back issues of their newsletter, Callback, are online.

  • The Old New Thing

    Do you know when your destructors run? Part 2.


    Continuing from yesterday, here's another case where you have to watch your destructors. Yesterday's theme was destructors that run at the wrong time. Today, we're going to see destructors that don't run at all!

    Assume there's an ObjectLock class which takes a lock in its constructor and releases it in its destructor.

    DWORD ThreadProc(LPVOID p)
      ... do stuff ...
      ObjectLock lock(p);
      ... do stuff ...
      return 0;

    Pretty standard stuff. The first batch of stuff is done without the lock, and the second batch is done inside the lock. When the function returns, the lock is automatically released.

    But suppose somebody adds a little code to this function like this:

    DWORD ThreadProc(LPVOID p)
      ... do stuff ...
      ObjectLock lock(p);
      if (p->cancelled) ExitThread(1);
      return 0;

    The code change was just to add an early exit if the object was cancelled.

    But when does that ObjectLock destructor run?

    It runs at the return statement, since that's when the lock goes out of scope. In particular, it is not run before you call ExitThread.

    Result: You left an object locked permanently.

    You can imagine how variations on this code could lead to resource leaks or other problems.

  • The Old New Thing

    You can do anything at zombo.com, anything at all


    Zombo has been around for many years, and yet I still find it hilarious (requires Flash).

    I just went back to check, and alas the introduction actually ends. But fortunately, they made it even cooler by having a text-only version. (Still requires sound.)

Page 393 of 432 (4,312 items) «391392393394395»