The Old New Thing

Why does the Run dialog autocorrect but not the Run key?

In an earlier comment, Aswin Gunawan asked why the Run dialog does autocorrection but not the Run key? One is a programmatic interface and the other is an end-user control. End users are not expected to be understand how computers do things. They want, and even expect, the computer to help them out with what they're typing. This means spell...

Displaying the dictionary, part 3: Using an owner-data listview

Owner-data listviews let you take over data management from the listview. This is useful in our case since we have over twenty thousand dictionary entries, and creating even that many blank listview items takes an unacceptably long amount of time. Let's convert our listview to an owner-data listview. Believe it or not, this is quite easy to...

Displaying the dictionary, part 2: Using text callbacks

As we noted last time, adding items to the listview takes an absurd amount of time. Today, we'll make a failed attempt at improving this because it lets me illustrate a listview technique and it lays the groundwork for the real fix next time. Instead of creating the items in their entirety, let's set their text to . This is a placeholder ...

Displaying the dictionary, part 1: Naive version

We return briefly to the ongoing Chinese/English dictionary series and write some code to display all the definitions we had worked so hard to collect. (I figure you're anxious to see something on the screen, so I am going to handle the Traditional Chinese/Simplified Chinese issue later. For now, the "Simplified" column will be blank.) ...

Answer to quick puzzle about security and synchronization

As many people quickly figured out, the reason why the the returns immediately is that the call is failing. The reason is that the second process opened the handle with access, which grants permission to call the function, the function, and the fatally flawed function, but it doesn't include access, which is necessary if you ...

A quick puzzle about security and synchronization

This quick puzzle floated past one of our internal discussion groups. In Process B, the succeeds, but the returns immediately instead of waiting. Explain. [Correction: I confused the matter by passing as the third parameter, thereby creating an event that is initially signalled. Change it to so that the event is created non-...

Using modular arithmetic to avoid timing overflow problems

In an earlier article, I presented a simple way of avoiding timing overflows which seemed to create a bit of confusion. The short version: Given a starting time start, an ending time end and an interval interval, the way to check whether the interval has elapsed is to use the expression . The naive expression suffers from integer overflow ...

You can't simulate keyboard input with PostMessage

Some people attempt to simulate keyboard input to an application by posting keyboard input messages, but this is not reliable for many reasons. First of all, keyboard input is a more complicated matter than those who imprinted on the English keyboard realize. Languages with accent marks have dead keys, Far East languages have a variety of ...

When is x/2 different from x>>1?

Everyone "knows" that the following pairs of expressions are equivalent: Too bad they aren't. In the C language standard, there is no requirement that the internal representation of signed integers be two's complement. All the permissible representations agree for positive numbers, but negative numbers can have different representations. If...

The effect of SetCursor lasts only until the next SetCursor

Of course the effect of the function for a thread lasts only until that thread changes the cursor to something else. Any moron knows that, right? The tricky part is that the may come from an unexpected place. THe most common place people run into this is when they do something like this: This puts up the hourglass during the ...