January, 2008

  • The Old New Thing

    What does it mean when a display change is temporary?


    When you call the ChangeDisplaySettings function, you can pass the CDS_FULLSCREEN flag to indicate that the change is temporary. But if you don't also save the changes in the registry, how can they be permanent? What does temporary mean?

    A temporary display change is one that your program has entered because it has gone into a fullscreen mode, a change which it will undo when it releases control of the screen to another program. For example, a fullscreen video may use a temporary display change to display a 320 × 200 video. The change isn't permanent, since the video player will certainly return the video resolution to its previous setting when the video ends or when the user switches to another program.

    The window manager and Explorer behave differently in response to temporary as opposed to permanent display changes. If a display change is permanent, the window manager will reposition windows and Explorer will reposition desktop icons so that they all fit on the (new) screen. If they didn't do this, then windows and icons near the right edge or bottom edge would become inaccessible. Conversely, if you say that the change is temporary, then the window manager and Explorer won't reposition anything because you said that you'll set things back when you're done.

    If you set the CDS_FULLSCREEN flag incorrectly, you typically see one of two results.

    If you set the temporary flag when you shouldn't, then you'll find that icons have disappeared off-screen and have become inaccessible. That's because you said, "Oh, don't worry about this screen resolution change. I'll set it back before you even realize it."

    If you fail to set the temporary flag when you should have, then you'll find that all your open windows and your desktop icons have been squished into the corner of the screen. And that's because you said, "The user is going to be working in screen resolution to 320 × 200, so you'd better make sure everything is ready for it!"

    Moral of the story: If you're going to change the display settings, make sure you correctly indicate whether you're doing this temporarily or permanently. The name for the flag CDS_FULLSCREEN acts as a strong hint for telling you when you need to pass it.

    Pre-emptive snarky comment: "This blog entry is proof that Microsoft documentation sucks. If the documentation were any good, this article would not have been necessary." Well, I'm sorry for trying to help. If you prefer, I'll only write about things that are already well-documented.

  • The Old New Thing

    In steady state, only geeks install Windows, but the hard part is getting to that steady state


    Commenter BryanK notes that only already-technical people (re)install Windows; commenter Stu estimates the percentage at 99%. That may be true in the steady state, but the hard part is getting to that steady state.

    When a new version of Windows is released, the steady state is disrupted. At that point, most people installing Windows aren't technical. They're your technology columnist who is installing Windows and viewing it through the eyes of a non-technical user, then writing a column about it. They're your average consumer who wants to check out this new operating system. These are the crazy people who stayed up late to buy the product at the stroke of midnight, and they're going to kick off an upgrade install once they get home. These initial impressions are crucial, and innundating the user with geeky questions they can't answer is not going to generate good buzz.

    The steady state is also disrupted every year at Christmas. The technology columnists are not as big a part of the picture, but the non-technical end users are still around, and Christmas is a common trigger for upgrading one's system.

    So even though non-technical people rarely install Windows, the steady state is upset every year. What's more, whenever a new release of Windows comes out all¹ the people who are installing Windows are non-technical. That's why it's important for the installation process to be as friendly to non-technical users as possible.

    ¹The word "all" here is about as accurate as the word "only" in the original comment.

  • The Old New Thing

    A new DUI record set in the state of Washington


    In case you missed it, a former Seattle police detective was arrested in early 2007 for driving with a state record high blood-alcohol level of 0.47 percent. (The legal limit is 0.08 percent, most people black out at 0.35 percent, and 0.40 percent is lethal for 50% of adults.) She was subsequently arrested and held on $250,000 bail (story contains other history of Ms. Jarrett). Bail was increased to $300,000 a week later, with another hearing scheduled for May for... a separate DUI case. At the May hearing, the initial attempt by the driver's attorneys to release their client to a treatment center failed, but a second attempt succeeded (second story).

    And then that's it. No more news I can find. I suspect we'll never learn whether the treatment program was deemed a success.

    Just as that saga appears to be winding down, a new one appears to be starting up: In neighbor state Oregon, a person with multiple drunken driving convictions was discovered with a blood alcohol level of a stunning 0.55 percent.

  • The Old New Thing

    You know the answer: Window destruction


    The following request for assistance came in from a customer, and given what you know about window destruction, you should eventually be able to figure it out yourself once all the pieces are in place, though it takes some time for all the clues to be revealed.

    We are hitting this exception in our program. This is urgent; please give it priority attention.

    0006f6ac kernel32!InterlockedCompareExchange+0xc
    0006f6ec comctl32!CImageListBase::IsValid+0x2a
    0006f6fc comctl32!HIMAGELIST_QueryInterface+0x2c
    0006f714 comctl32!ImageList_GetBkColor+0x1b
    0006f724 comctl32!TV_HasTransparentImage+0x1c
    0006f744 comctl32!TV_SelectItem+0x1a
    0006f7d4 comctl32!TV_DeleteItemRecurse+0x12a
    0006f85c comctl32!TV_DeleteItemRecurse+0x58
    0006f87c comctl32!TV_DeleteItem+0x8c
    0006f89c comctl32!TV_DestroyTree+0x90
    0006f900 comctl32!TV_WndProc+0x2e7
    0006f92c USER32!InternalCallWinProc+0x23
    0006f9a4 USER32!UserCallWinProcCheckWow+0x14b
    0006fa00 USER32!DispatchClientMessage+0xda
    0006fa28 USER32!__fnDWORD+0x24
    0006fa54 ntdll!KiUserCallbackDispatcher+0x2e
    0006fa58 USER32!NtUserDestroyWindow+0xc
    0006faac comctl32!_RealPropertySheet+0x307
    0006fac0 comctl32!_PropertySheet+0x45
    0006fad0 comctl32!PropertySheetW+0xf
    0006fbc4 abc!Wizard::ModalExecute+0x17c
    0006fc50 abc!RunWizard+0x564
    0006fcac abc!Start+0x185
    0006fd70 abc!ABCEntryW+0x2b9
    0006ff5c abc!wmain+0x7db
    0006ffa0 abc!__tmainCRTStartup+0x10f
    0006ffac kernel32!BaseThreadInitThunk+0xe
    0006ffec ntdll!_RtlUserThreadStart+0x23

    The proximate problem is that the treeview control is trying to use an imagelist that is no longer valid, probably because it has already been destroyed. If you look at the stack, you can see that the treeview control is being destroyed. You might infer this from the function named TV_DestroyTree, or if you look at the parameters, which I removed from the stack trace for brevity, you would see that the message is WM_DESTROY.

    The next step in unwinding the problem is figuring out who destroyed the imagelist while it was still in use. The customer shared their source code, and a little bit of spelunking revealed that it was this function which destroyed the imagelist:

       if (m_hImageList)

    Now all the clues to the puzzle have been laid out on the table. Use your fantastic powers of deduction to see where the customer went wrong. To refresh your memory, you might want to read this old blog entry.

    (And now that you've seen and understood this problem, in the future you can jump from the stack trace directly to the conclusion, thereby exhibiting your psychic debugging powers.)

  • The Old New Thing

    Fact of life: People can't see things that are right in front of them


    A bug report came in:

    When I go to the Power Options control panel and select Edit Plan Settings, the Turn off display combo-box is disabled. Is this a bug?

    Shortly thereafter, this response was submitted:

    Do you see a big yellow warning over the Turn off display that says that some settings are managed by your system administrator, and a link called Why can't I change some settings?

    The reply:

    Yes, my machine is joined to a domain, and I see that yellow warning.

    This is a fact of life. People can't see what is right in front of their face. Even though there's a warning right above the disabled item explaining that it can't be changed due to an administrative setting, even though there's a link on the page whose text directly addresses the issue they are asking about, even though they confirm the existence of the explanatory text when asked, they still don't read it or understand it. It's another case of inattentional blindness. You are so focused on the task of clicking on the combobox that you completely disregard any other information because you simply aren't expecting it to be there.

Page 4 of 4 (35 items) 1234