Showing results for Code - The Old New Thing

Apr 9, 2007
Post comments count0
Post likes count0

Why doesn't the taskbar return to its original size when I return my settings to their original values?

Raymond Chen
Raymond Chen

Commenter Gareth asked why, when the system metrics change and the taskbar changes size to match, the taskbar doesn't return to its original size when the metrics return to their previous values. Because the taskbar doesn't remember the path of changes that led to its current state. It just knows its current state. Let's say the taskbar is 30 pi...

Code
Apr 5, 2007
Post comments count0
Post likes count0

Why can't I display a tooltip for a disabled window?

Raymond Chen
Raymond Chen

Here's a question that floated past my field of view some time ago: When the mouse hovers over a disabled window, the tooltip associated with that window does not appear. Why is this? Why isn't this documented in MSDN? Actually, you already know the answer, and it is documented. You just have to connect the dots. When a window is disabled, it d...

Code
Mar 29, 2007
Post comments count0
Post likes count0

The buffer size parameter to GetFileVersionInfo is the size of your buffer, no really

Raymond Chen
Raymond Chen

The function takes a pointer to a buffer () and a size (), and that size is the size of the buffer, in bytes. No really, that's what it is. The application compatibility folks found one popular game which wasn't quite sure what that parameter meant. The programmers must have thought it meant "The size of the version resources you want to loa...

Code
Mar 26, 2007
Post comments count0
Post likes count0

Passing by address versus passing by reference, a puzzle

Raymond Chen
Raymond Chen

Commenter Mike Petry asked via the Suggestion Box: Why can you dereference a COM interface pointer and pass it to a function with a Com interface reference. The call. The function called. I found some code written like this during a code review. It is wrong but it seems to work. You already know the answer to this question. You mere...

Code
Mar 23, 2007
Post comments count0
Post likes count0

Excursions in composition: Adding rewind support to a sequential stream

Raymond Chen
Raymond Chen

Here's a problem "inspired by actual events": I have a sequential stream that is the response to a request I sent to a web site. The format of the stream is rather messy; it comes with a variable-length header that describes what type of data is being returned. I want to read that header and then hand the stream to an appropriate handler. But t...

Code
Mar 22, 2007
Post comments count0
Post likes count0

Excursions in composition: Sequential stream concatenation

Raymond Chen
Raymond Chen

As we've seen a few times already (when building context menus and exploring fiber-based enumeration), composition is an important concept in object-oriented programming. Today, we're going to compose two sequential streams by concatenation. There really isn't much to it. The idea is to take two streams and start by reading from the first one....

Code
Mar 19, 2007
Post comments count0
Post likes count0

How do the menu functions find items?

Raymond Chen
Raymond Chen

Most of the menu item functions such as allow you specify the menu item either by position or by command. Some of them use the and flags. Others separate the search algorithm into a separate flag. Searching for menu items by position is straightforward: The specified position is used as a zero-based index into the menu. In other words, the fir...

Code
Mar 16, 2007
Post comments count0
Post likes count0

The format of accelerator table resources

Raymond Chen
Raymond Chen

Continuing in the extremely sporadic series on the format of resources, today we'll take a look at accelerator tables. This topic is so simple, I'll cover both 16-bit and 32-bit resources on the same day! In 16-bit Windows, the format of an accelerator table resource was simply an array of structures. This array is the same array you would ...

Code
Mar 13, 2007
Post comments count0
Post likes count0

The only thing you can do with display names is display them

Raymond Chen
Raymond Chen

There are many functions that return strings called "display names". And the only thing you can do with display names is display them. Don't assume that the string actually means anything, because it doesn't. Theoretically, a function like could be implemented as and your program should still work. (Of course, this is merely a ground rule. S...

Code