September, 2007

  • The Old New Thing

    2007 Q3 link clearance: Microsoft blogger edition


    A few random links that I've collected from other Microsoft bloggers.

  • The Old New Thing

    2007 Museum Day, courtesy of Smithsonian Magazine


    It's the end of September, which means that once again, it's time for Smithsonian Magazine's annual Museum Day, so search for a participating museum near you and get your free admission card.

    One of the participating museums is the Museum of History & Industry, known to locals by its initials, MOHAI. Whenever I go past the museum and see the big MOHAI banners, I think to myself how great it would be if they opened a satellite location in, say, Renton. That museum would be called the Museum of History & Industry, Renton, or MOHAIR for short.

  • The Old New Thing

    Why did the shortcut template change in Windows Vista?


    Since Windows 95, when you right-dragged an item and selected "Create Shortcut", you got "Shortcut to X". But in Windows Vista, the name is now "X - Shortcut". Why is that?

    Two reasons.

    The first reason is globalization. The template "Shortcut to X" made X the object of a preposition. In some languages, this may require changes to X (for case) or to the word "to" (based on grammatical properties of X). Constructing sentences from phrases is a dangerous endeavor due to language issues like this, and the new formulation sidesteps the issue by not trying to make a phrase out of the result.

    The second reason is sorting. With the new format, the shortcut sorts next to the original object, making it easier to find. (This is particularly helpful when you're in an auto-sort view. "Hey, where's that shortcut I just created? Oh well, I'll just make another one.")

  • The Old New Thing

    The first day at Microsoft: A fender-bender


    This is the first of what might be a series of stories on the subject, So what happened on your first day at Microsoft? Some facts may have been altered to preserve the anonymity of the subject, but the essense is true. Our first storyteller is "Employee X":

    At the end of my first day, I back out of my parking space and accidentally hit a Lexus parked behind me. Oh great, my first day at work, and I dent somebody's fancy car. I leave a note of apology on the windshield, with my name, email address, phone number, and a promise to pay for whatever repairs are necessary.

    The next day, I come to work, and I have a new email message.

    From Bill Gates.

    Oh my God, I dented Bill Gates' car.

    Fortunately, he said not to worry about it.

    Bonus: Russell Ball shares a voicemail message left by a new employee on his second day.

  • The Old New Thing

    Microspeak: Going forward


    The jargon phrase going forward has largely replaced the more mundane equivalent from now on. It appears that I'm not the only person who is bothered by this phrase. Sample usages:

    • We discussed the membership and timeframe for support team meetings going forward.
    • There will be change to the status reports going forward.
    • Going forward we will be doing this for every milestone.

    Notice that the phrase going forward usually adds little to the sentence. You can delete it from all of the sentences above and nobody would notice a difference.

  • The Old New Thing

    How do I put a different wallpaper on each monitor?


    When you set a wallpaper on a multi-monitor system, that wallpaper goes onto each monitor. For example, if your wallpaper is a picture of a flower, each monitor shows that same flower. Commenter David Phillips wonders whether there is a way to set a different wallpaper on each monitor, or whether it is some sort of trick.

    It's some sort of trick.

    And it's a trick because it's not something that the window manager folks intended to happen; rather, it's just an artifact of how wallpapers work.

    The trick is to set your wallpaper to "tile" rather than "center" or "stretch". When the window manager draws a tiled bitmap, it places the tiles so that the upper left corner of the primary monitor exactly coincides with the top left corner of a tile. The remaining tiles are then arranged around that anchor tile.

    You're not listening. I said that I wanted a different picture on each monitor, not the same picture tiled across all of my monitors.

    Yes, I know. Here comes the trick: Create a "monster tile". For example, suppose you have two 800×600 monitors arranged side by side (primary on the left), and you want a tropical island on the primary monitor and a country road sunset on the second, like this:

    Create a single bitmap that consists of the two images side by side. In our case, it would be a single 1600×600 bitmap.

    When this bitmap is tiled, the "virtual infinite screen" looks like this:

    And the upper left corner of the primary monitor lines up against the upper left corner of a tile, like so:

    If your monitors aren't the same size, you can still use this trick; you just need to add some dummy space to get the tiles to line up the way you want. For example, suppose your secondary monitor is smaller than your primary, positioned so that its top edge lines up with the top edge of the primary. Your "monster bitmap" would place the country road sunset in the corresponding position next to the bitmap you want to use for your primary monitor.

    When this bitmap is tiled and the upper left corner of the tile is placed at the upper left corner of the primary monitor, you get the desired effect:

    Ah, but what if you have a monitor above or to the left of your primary monitor? Since the bitmap is tiled, you just "wrap around" from the left of the "monster bitmap" to the extreme right. For example, if your monitors are arranged side by side but you have the secondary monitor on the left, then you still put the image for the secondary monitor on the right; that way, when the origin of your monitor system is placed against a tile, the image from the tile to the left is the one that shows up on your secondary monitor.

    Given these examples, I leave you to develop the general algorithm.

  • The Old New Thing

    The Microsoft Cafeteria Tour (Redmond 2006 Edition)


    In 2006, Christian Buckley set forth on a grand mission: To visit every cafeteria on Microsoft's Redmond campus. This marathon effort went by the name Microsoft Cafeteria Tour 2006, or for those in the know, MSCT2k6.

    Those looking for off-campus dining options can make use of this map mashup of restaurants which provide discounts to Microsoft employees. (Note: Rumored to be out of date, but still a useful starting point.)

  • The Old New Thing

    What's the BS_PUSHLIKE button style for?


    One of the lesser-known button styles is BS_PUSHLIKE.

    Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn't pushed or checked, and sunken when it is pushed or checked.

    In other words, you add this style to a check box or radio button to make it look like a push button even though it will continue to act like a check box or radio button.

    Check box Check box
    Radio button Radio button
    Unselected Label Label Label Label
    Selected Label Label Label Label

    Aside from the appearance, the other checkbox and radio button behaviors are preserved. Each time you click an automatic check box, it toggles between unselected and selected; it's just that instead of hiding and showing the check-mark, it pops the button out and pushes the button in. Similarly, the automatic radio button becomes selected when you click on it and becomes deselected when you select another radio button in the group. All that changed is the visuals.

    Let's illustrate this with a quick sample program. First, we'll use traditional check boxes and radio buttons.

    1 DIALOG 64, 64, 100, 70
    CAPTION "Demo"
    FONT 8, "MS Shell Dlg"
        AUTORADIOBUTTON "Search &forward", 100, 4, 9,
                  75, 14, WS_GROUP | WS_TABSTOP
        AUTORADIOBUTTON "Search &backward", 101, 4, 27,
                  75, 14
        AUTOCHECKBOX "&Ignore case", 102, 4, 45,
                  75, 14, WS_TABSTOP
        HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
     switch (uMsg) {
      case WM_INITDIALOG: return TRUE;
      case WM_CLOSE: EndDialog(hdlg, 1); break;
     return FALSE;
    int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev,
                       LPSTR lpCmdLine, int nShowCmd)
      DialogBox(hinst, MAKEINTRESOURCE(1), 0, DlgProc);
      return 0;

    When you run this program, you get two radio buttons and a check box, and there's nothing special about them at all. But add the BS_PUSHLIKE style...

    1 DIALOG 64, 64, 100, 70
    CAPTION "Demo"
    FONT 8, "MS Shell Dlg"
        AUTORADIOBUTTON "Search &forward", 100, 4, 9,
                  75, 14, WS_GROUP | WS_TABSTOP | BS_PUSHLIKE
        AUTORADIOBUTTON "Search &backward", 101, 4, 27,
                  75, 14, BS_PUSHLIKE
        AUTOCHECKBOX "&Ignore case", 102, 4, 45,
                  75, 14, WS_TABSTOP | BS_PUSHLIKE

    and now the radio buttons and check box look like push buttons. But if you click on them, they still behave like two radio buttons and a check box. if you select "Search forward", then "Search backward" automatically de-selects itself, and vice versa. Each time you click on "Ignore case", it toggles between pushed-in and popped-out.

    The visuals are kind of confusing, however, if you have enabled Windows XP visual styles, for when you hover over a button, the theme engine will draw the button in its "hover" appearance, which causes it to pop out even though the button really is pushed in. You have to move the mouse away from the button to see that it really is pushed in. Personally, I consider this a bug. The situation in Windows Vista is only slightly better; it's still pretty bad.

    Push-like buttons are not used much since they duplicate the semantics of radio buttons and check boxes while presenting a deceptive visual appearance. Since they look like push buttons, users naturally expect them to behave like push buttons, and then when they don't, things get confusing. The only case I can think of off the top of my head where push-like buttons actually match with user expectations is in toolbars, where there is a long-standing convention of using push-like buttons in toolbars instead of radio buttons and check boxes. (Fortunately, toolbars manage their own buttons and don't suffer from the confusing hover-appearance behavior I discussed above.)

  • The Old New Thing

    Find the Flowers vs Minesweeper


    David Vronay writes about the difficult balance that has to be maintained between people who like the classic Windows game Minesweeper and people who are (understandably) upset that Windows includes a game about landmines, trivializing a very serious issue. (Yes, the image used in the game is a water mine, not a land mine, but that's scant consolation.)

    By the way, David, you see, the idea behind "Find the Flowers" is that it's bad to step on flowers.

  • The Old New Thing

    It rather involved being on the other side of this airtight hatchway: Elevation to administrator


    Surprisingly, it is not a security vulnerability that administrators can add other users to the Administrators group. But that doesn't stop people from claiming that it is.

    For example, it's not uncommon for a vulnerability report to come in with the following steps:

    1. (a) Install this rogue service/driver, or (b) copy this rogue program to your machine and change this registry key in HKEY_LOCAL_MACHINE to point to it, or (c) replace this file in the system directory with a rogue program.
    2. Log on as an unprivileged user.
    3. Perform magical operation X.
    4. Boom! User is now an administrator!

    Wow, this looks bad. An unprivileged user can elevate to administrator and... wait a second, what's that in step 1?

    To perform step 1, you need to have administrative privileges already. Only administrators can install services and drivers, only administrators can change registry keys in HKEY_LOCAL_MACHINE, and only administrators have write permission in the system directory. Therefore, this "vulnerability" basically says "If you can gain administrator privileges, then you can add anybody to the Administrators group." Well, sure, but you really chose the complicated way of doing it. Once you get administrator privileges, just do a NET LOCALGROUP Administrators Fred /ADD and you're done.

    After all, why write a service or a driver when a batch file does the trick just as easily?

    An alternative step 4 is "Boom! User is pwnz0red!" Well, yeah, an administrator can install software that commandeers user accounts. This is hardly a surprise, is it?

    In a sense, this is "security vulnerability by obscurity": By making your alleged exploit unnecessarily complicated, you can fool people into thinking that you're actually onto something.

Page 1 of 4 (36 items) 1234