Showing results for Code - The Old New Thing

Aug 30, 2005
Post comments count0
Post likes count0

Program names in file type handlers need to be fully-qualified

Raymond Chen
Raymond Chen

Most people probably haven't noticed this, but there was a change to the requirements for file type handlers that arrived with Windows XP SP 2: Paths to programs now must be fully-qualified if they reside in a directory outside of the Windows directory and the System directory. The reason for this is security with a touch of predictabil...

Code
Aug 17, 2005
Post comments count0
Post likes count0

Why is processor affinity inherited by child processes?

Raymond Chen
Raymond Chen

Consider why a typical program launches child processes. (Shell programs like Explorer aren't typical.) It's because the task at hand is being broken down into sub-tasks which for whatever reason has been placed into a child process. An Example of this would be, say, a multi-pass compiler/linker, where each pass is implemented as a separate proces...

Code
Aug 15, 2005
Post comments count0
Post likes count0

The poor man’s way of identifying memory leaks

Raymond Chen
Raymond Chen

There is a variety of tools available for identifying resource leaks, but there's one method that requires no tools or special compiler switches or support libraries: Just let the leak continue until the source becomes blatantly obvious. Nightly automated stress testing is a regular part of any project. Some teams use screen savers as the trigger...

Code
Aug 12, 2005
Post comments count0
Post likes count0

Adding a lookup control to the dictionary: Searching Pinyin

Raymond Chen
Raymond Chen

Finally we start searching. For now, the search algorithm is going to be very simple: The string you type into the edit control will be treated as the start of a Pinyin word or phrase. We'll make it fancier later. Here is where a lot of the groundwork (some of which I called out explicitly and some of which I slipped in without calling attention...

Code
Aug 11, 2005
Post comments count0
Post likes count0

Adding a lookup control to the dictionary: Just getting it on the screen

Raymond Chen
Raymond Chen

When we last left the dictionary project, we were able to display the dictionary entries but hadn't yet gotten around to searching it. Today, we'll place the lookup control, though we won't hook it up until next time. First, we give the edit control an ID and create some member variables to keep track of it. class RootWindow : public Window { ...

Code
Aug 9, 2005
Post comments count0
Post likes count0

The dangers of messing with activation when handling a WM_ACTIVATE message

Raymond Chen
Raymond Chen

This is basically the same thing as The dangers of playing focus games when handling a WM_KILLFOCUS message, just with activation in place of focus. One developer discovered the hard way that if you mess with activation inside your WM_ACTIVATE handler, things get weird. The author noted that if he posted a message and did the work from the posted...

Code
Aug 8, 2005
Post comments count0
Post likes count0

The dangers of playing focus games when handling a WM_KILLFOCUS message

Raymond Chen
Raymond Chen

I had noted last year that WM_KILLFOCUS is the wrong time to do field validation. Here's another example of how messing with the focus during a WM_KILLFOCUS message can create confusion. Consider an edit control that displays feedback via a balloon tip. For example, password edit controls often warn you if you're typing your password while Caps...

Code
Aug 5, 2005
Post comments count0
Post likes count0

Why does the Internet Explorer animated logo arrange its frame vertically?

Raymond Chen
Raymond Chen

If you ever tried to build a custom animated logo for Internet Explorer, you cetainly noticed that the frames of the animation are arranged vertically rather than horizontally. Why is that? Because it's much more efficient. Recall that bitmaps are stored as a series of rows of pixels. In other words, if you number the pixels of a bitmap like ...

Code
Aug 4, 2005
Post comments count0
Post likes count0

Double-clicking radio buttons

Raymond Chen
Raymond Chen

A subtlety that adds a level of polish to your dialogs is supporting double-clicked radio buttons as an abbreviation for "select + OK". (Or "select + Next" or "select + Finish" if the page is part of a wizard.) Consider the following dialog template and associated dialog procedure: 1 DIALOGEX DISCARDABLE 32, 32, 200, 76 STYLE DS_MODALFRAME | ...

Code
Aug 3, 2005
Post comments count0
Post likes count0

Drawing a monochrome bitmap with transparency

Raymond Chen
Raymond Chen

Last time, I left you with a brief puzzle. Here are two approaches. I am not a GDI expert, so there may be even better solutions out there. To emphasize the transparency, I'll change the window background color to the application workspace color. BOOL WinRegisterClass(WNDCLASS *pwc) { pwc->hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1);...

Code