• The Old New Thing

    What two-year-olds think about when they are placed in time-out

    • 10 Comments

    My niece (two years old at the time) was put in the corner as punishment for some sort of misdeed. At the expiration of her punishment, her grandfather returned and asked her, "你乖唔乖?" (Are you going to be nice?)

    She cheerfully replied, "仲未乖!" (Still naughty!)

    In an unrelated incident, one of my honorary nieces was being similarly punished. She told her aunt who was passing nearby, "In a little while, my daddy is going to ask me if I'm sorry. I'm not really sorry, but I'm going to say that I am."

  • The Old New Thing

    Nieces sometimes extrapolate from insufficient contextual data

    • 10 Comments

    My brother-in-law enjoys greeting his nieces when they come over to visit by throwing them into the air and asking, "叫聲我?" (Who am I?)

    The nieces happily reply, "舅舅." (Uncle.)

    He then tosses them up into the air a second time and says, "大聲啲!" (Louder!)

    And the nieces happily shout, "舅舅!"

    One time, my wife was talking with her brother at a normal volume, and his niece came into the room and said to my wife, "大聲啲! 舅舅聽唔到!" (Louder! Uncle can't hear you!)

    Update: Per Frank's suggestion below, changed the niece's outburst from "舅舅冇聽到!" The incident occurred many years ago, and I cannot remember exactly what was said, so I'll go with what's funnier.

  • The Old New Thing

    The Grand Duke's monocle is an affectation

    • 10 Comments

    In the Disney adaptation of Cinderella, the Grand Duke wears a monocle. The monocle moves from eye to eye during the course of the story.

    The Grand Duke's monocle is an affectation.

    Either that, or he needs a full pair of glasses, but is very frugal.

  • The Old New Thing

    We know your job is hard, you don't have to show us

    • 10 Comments

    Some years ago, I attended a internal presentation where one group was teaching another group how to use their new feature. This particular feature was a "Just plug in the things you want, click the Apply button, and sit back and relax while we figure out how to do what you asked" type of feature.

    The presentation leader showed some examples of the feature in action, and gave some clear, concise guidance on how the feature should be used, guidance like "Use Pattern A when the user is faced with a choice between two clear options, but use Pattern B when the situation is more open-ended." So far so good.

    The next part of the presentation was given to the feature's lead designer. The lead designer called out some design principles that the feature adhered to. For example, "Notice that we always position the Widget above the Frob."

    But then the lead designer started getting into details that were basically a fifteen-minute way of saying, "Look how hard our job is." The designer called up the graphic design software, showing off the bazillion buttons and sliders and switches that the designers used to fine-tune the colors, gradients, and shading. The designer then went through the animation storyboard templates and showed how each of the carefully-plotted curves achieves the desired visual effect.

    Once we reached the "Look how hard our job is" portion, the presentation ground to a halt.

    The lead designer lost sight of the fact that all this information about how hard the feature was to design was not actionable. The attendees did not need this information in order to use the feature effectively. It was just showing off for the sake of showing off, and it basically wasted everybody's time.

  • The Old New Thing

    I think we're going to be getting frozen leftovers for lunch today

    • 10 Comments

    There are a few times a year when a large fraction of employees are out on vacation at the same time, such as a single work day wedged between a holiday and a weekend (as happened this year on July 5). The most extreme case of this is the week between the Christmas holiday and New Year's Day, where the offices are practically empty. On these days of low demand, many services are scaled back and some choose to close entirely so that they can do inventory, perform routine maintenance, or upgrade equipment.

    One of the most visible service reductions is in food service. Smaller locations (such as snack bars) are closed, and the kitchens which remain open offer a reduced menu. But just because most people are on vacation doesn't mean that nobody is watching. Here's a menu from one kitchen that was posted almost exactly one year ago:

    Breakfast Roberts Waffles
    Breakfast Burrito
    Warm Tortilla filled with Scrambled Egg, Golden Hash Browns, Onion Green Chiles, Monterey Jack Cheese and Salsa.
    Today's Soups Clam Chowder
    Tomato Basil Bisque
    Exhibition Station Closed for Holiday
    Shanghai Shanghai
    Greek Potato Salad
    A delicious blend of potatoes, tomatoes, red onions, flavored with mustard, parsley, dill seed, mint and lemon juice.
    Wild Greens Grill and Greens
    Chef's Table Station Closed for Holiday
    Pizza Specialty Pizza by the Slice
    Deli Mozzarella, Tomato and Basil Panini
    Mozzarella, Tomato and Basil Panini
    Spcied [sic] Cranberry Turkey Salad Served on a Flaky Crossaint [sic]
    Entrée Check Freezer
    Grill Tuna Melt
    Steak Frites
  • The Old New Thing

    There are so many things that call themselves message queues

    • 10 Comments

    There are a whole bunch of things in Windows that call themselves message queues, and none of them have anything to do with each other.

    There is the window manager message queue, which holds window messages.

    And there is the Microsoft Message Queue (MSMQ) which is a networking technology for allowing multiple computers to communicate with each other by sending and reading messages.

    The Windows Mobile folks didn't want to feel left out, so they created their own Message Queue Point-to-Point message queue system.

    These are all unrelated technologies. Trying to, say, read window messages from a MSMQ message queue will get you nowhere.

  • The Old New Thing

    How do I get a high resolution icon for a file?

    • 10 Comments

    Today's Little Program obtains a high resolution icon for a file.

    Start with our scratch program and make these changes. Remember, Little Programs do little or no error checking. This week's smart pointer class is (rolls dice) _com_ptr_t!

    ...
    #include <shlwapi.h>
    #include <commoncontrols.h>
    #include <comip.h>
    #include <comdef.h>
    
    _COM_SMARTPTR_TYPEDEF(IImageList, __uuidof(IImageList));
    
    HICON g_hico;
    
    HINSTANCE g_hinst;                          /* This application's HINSTANCE */
    ...
    
    int GetIconIndex(PCTSTR pszFile)
    {
      SHFILEINFO sfi;
      SHGetFileInfo(pszFile, 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX);
      return sfi.iIcon;
    }
    
    HICON GetJumboIcon(int iImage)
    {
      IImageListPtr spiml;
      SHGetImageList(SHIL_JUMBO, IID_PPV_ARGS(&spiml));
    
      HICON hico;
      spiml->GetIcon(iImage, ILD_TRANSPARENT, &hico);
      return hico;
    }
    

    The Get­Icon­Index function does nothing new. It simply retrieves the system image list icon index for a file's icon.

    The Get­Jumbo­Icon retrieves an icon by its system image list index. First, it asks SHGet­Image­List for the jumbo image list, then it asks the jumbo image list for the icon.

    Now all we have to do is hook the functions up.

    void
    PaintContent(HWND hwnd, PAINTSTRUCT *pps)
    {
      DrawIconEx(pps->hdc, 50, 50, g_hico,
                 0, 0, 0, nullptr, DI_NORMAL);
    }
    
        ...
        if (SUCCEEDED(CoInitialize(NULL))) {/* In case we use COM */
    
            g_hico = GetJumboIcon(GetIconIndex(lpCmdLine));
    
            ...
            DestroyIcon(g_hico);
            CoUninitialize();
        }
        ...
    

    Run this program and pass the full path to a file on the command line. (No quotation marks, even if it contains spaces!) Result: A gigantic icon for the file appears.

    Instead of converting the system imagelist index into an icon, we could just ask the jumbo imagelist to render it directly.

    int g_iImage;
    
    void
    PaintContent(HWND hwnd, PAINTSTRUCT *pps)
    {
      IImageListPtr spiml;
      SHGetImageList(SHIL_JUMBO, IID_PPV_ARGS(&spiml));
    
      IMAGELISTDRAWPARAMS ildp = { sizeof(ildp) };
      ildp.himl = IImageListToHIMAGELIST(spiml);
      ildp.i = g_iImage;
      ildp.hdcDst = pps->hdc;
      ildp.x = 50;
      ildp.y = 50;
      ildp.rgbBk = CLR_NONE;
      ildp.fStyle = ILD_TRANSPARENT;
      spiml->Draw(&ildp);
    }
    
        ...
        if (SUCCEEDED(CoInitialize(NULL))) {/* In case we use COM */
    
            g_iImage = GetIconIndex(lpCmdLine);
    
            ...
            // no cleanup necessary
            CoUninitialize();
        }
        ...
    

    This is how Explorer deals with icons most of the time. It doesn't create actual icons; it merely remembers indices into the system imagelist, and when it needs to draw an icon, it calls the Draw method on the imagelist whose size corresponds to the image it wants.

    Bonus chatter: The system imagelists come in four sizes (as of this writing). And yet large is one of the smallest available ones. Why is that?

    The system imagelist sizes are

    • Small
    • Large
    • Extra-Large
    • Jumbo

    The first two (small and large) were the only ones available in Windows 95. Windows XP added a size larger than large, which was named extra-large. And then Windows Vista added another size even larger than extra-large, which I named jumbo.

    It's an artifact of history that one of the smallest icon sizes has the name large. It was the largest icon size at the time, but things got even larger since then.

  • The Old New Thing

    How do I configure the timeout used by UI0Detect (Interactive Services Detection service)?

    • 10 Comments

    Windows Vista introduced Session 0 Isolation which enforces the rule that services should not display UI. If a service tries to display UI, another service known as the Interactive Services Detection service detects this situation and signals the user that a service wants to display UI and gives the user an opportunity to switch to the service desktop, respond to the UI, and then switch back. If the user ignores the service for about one minute, it switches back automatically, on the assumption that something went bad with the detection and the service is actually finished with its UI. (That way, the user doesn't get stuck staring at session 0 forever.)

    More than one customer wanted to know how to configure this one minute timeout.

    The correct solution to the problem is not to configure Interactive Services Detection but rather to fix your service so it doesn't show UI in session 0.

    It's like saying, "When I mail a letter and get the postal code wrong, the letter reaches the destination eventually, but it takes much longer than a letter sent with the correct postal code. How can I get letters sent with the incorrect postal code to reach their destination faster?"

    The answer is to stop putting the incorrect postal code on your letters.

    In other words, stop throwing garbage on the sidewalk.

    Bonus reading: Troubleshooting Interactive Services Detection.

  • The Old New Thing

    This was only a test; if this had been an actual concert...

    • 10 Comments

    I dreamed that there was a fire in Benaroya Hall during a concert. The flames swirled overhead up by the ceiling.

    The exit doors had been blocked by security, so people flowed from door to door looking for a way out.

    Ha-ha, it was just a drill, and the flames were pyrotechnics.

    This dream brought to you by Great Ideas in Public Safety.

  • The Old New Thing

    My friend lived in an apartment inside a museum

    • 10 Comments

    One evening, I had a series of three dreams. In each one, I visited an unusual home.

    In the second dream, I visited the home of a friend of mine. She lived in a modern luxury apartment inside an art museum. It was a little tricky, because you could visit her only during museum hours. If you stayed past closing time, then you were locked inside the museum, and you were spending the night whether you liked it or not.

    On the other hand, it meant that you could go out an view the art to your heart's content without any crowds.

    And no, the museum did not come to life. You just got free run of a museum for the night.

Page 370 of 457 (4,568 items) «368369370371372»