The Old New Thing

Answer to yesterday's exercise

iMin is the lowest-index element which intersects the paint rectangle, so a
simple truncating division produces the desired index.

The formula for iMax can be interpreted two ways. One is that it is the roundup
of the first invisible line. Recall the rectangles are exclusive of the endpoint,

Why doesn't the new Start menu use Intellimenus in the All Programs list?

Common request:
I want to be able to turn on personalized menus (Intellimenus) when in XP Start Menu mode.
Imagine if Intellimenus were enabled with the XP Start Menu.
You use 5 apps; the rest are not used much. (Studies show that 5 is the typical number of unique applications users run on a regular basis.

Scrollbars, part 3: Optimizing the paint cycle

Observe that we paint all 100 lines in our paint handler, even though most of them
aren’t visible. This is a problem if there are a large number of items, or if painting
an item is time-consuming.

So instead, we optimize our paint cycle so as to paint only the elements which intersect
the paint rectangle.

Why doesn't Windows have an "expert mode"?

We often get requests like this:
There should be a slider bar somewhere, say on the Performance Tab, that ranges from Novice to Advanced. At the highest level, all the geek settings are turned on. At the Novice level, all the settings for beginners are turned on.

Scrollbars, part 2

Managing scrollbars is not hard in principle. The basic idea is not that difficult,
but there are a lot of small details that need to be ironed out. If you don’t get
the details just right, your program will feel odd in a strange way that you often
can’t pinpoint,

More terse Q&A on Tweak UI 2.10

I’m going to try to alternate between programming entries (where I actually try to teach something) and random entries (where I get to spout off or go into storytelling mode). So here’s another random entry.

Why does Tweak UI put up a totally incomprehensible error message (“Cannot locate entrypoint GetDllDirectoryW in Kernel32.dll”) when I try to run it on an unsupported OS?

The scratch program

Occasionally, there is need to illustrate a point with a full program. To avoid reproducing the boring parts of the program, let’s agree on using the following template for our sample programs.
For expository purposes, I won’t use a C++ class.

Tweak UI 2.10

What are you talking about?
Tweak UI is part of the Windows XP PowerToys. It was recently updated to version 2.10.
What OS is required?
Windows XP Service Pack 1 (or higher) or Windows Server 2003 (all versions). Not supported: Windows XP RTM,

Old New Thing

A sneaky way to make sure nobody assigns test failures to your team

Buffer overflow.

Are Windows Runtime asynchronous operations guaranteed to complete?

As much as anything is guaranteed to complete.

If you say that your minimum requirements are the Universal contract, then you need to probe for anything beyond that

Reaching beyond your declaration.

How can I check whether a Windows Runtime object supports a member before I try to use it?

You can sniff at the metadata.

Accessing a member of a Windows Runtime class raises an Invalid­Cast­Exception / throws a hresult_no_interface, what does this mean?

It's interfaces under the hood.

Why not just share a single event across all critical section?

How will you know when the thundering herd has calmed down?

The security check happens at the acquisition of the handle

Once you buy a handle, it's yours to keep.

Further refinements to the attempt to create a type-dependent expression that is always false

It still falls down, but for stranger reasons.

It rather involved being on the other side of this airtight hatchway: Booting into another operating system

It's not your computer any more.

We called it RAID because it kills bugs dead

The history of defect tracking databases in Windows.