The Old New Thing

There can be more than one (or zero): Converting a process to a window

A common question I see is "How do I find the window that corresponds to an ?" This question comes pre-loaded with the assumption that there is only one window that corresponds to an , which is true for only the most rudimentary of Win32 programs. Even a simple program like Notepad has more than one window with the same , as Spy quickly ...

Why does Explorer show a + sign even if there are no child folders?

Mike Williams asked in the Suggestion Box why Explorer shows a + sign next to a folder even though it doesn't have any children. Mind you, this wasn't a suggestion; it was just a random question. I don't enjoy answering random questions about specific details of user interface elements since, as it turns out, I did not write every single user...

There's more to switching stacks than just loading a new stack pointer

Sometimes people think they can switch stacks by just loading a new value into the register. This may seem to work but in fact it doesn't, because there is more to switching stacks than just loading a new value into . On the x86, the exception chain is threaded through the stack, and the exception dispatch code verifies that the exception ...

Who decides what can be done with an object or a control?

This is one of those things that is obvious to me, but perhaps is not obvious to everyone. An object establishes what can be done with it. Any rights granted by the object go to the creator. The creator can in turn grant rights to others. But if you're a third party to the object/creator relationship, you can't just step in and start messing ...

DLL forwarding is not the same as delay-loading

As I noted earlier, when you create a forwarder entry in an export table, the corresponding target DLL is not loaded until somebody links to the forwarder entry. It looks like some people misread this statement to suggest some sort of delay-loading so I'm going to state it again with an example in mind in the hopes of clearing up any ...

Use WM_WINDOWPOSCHANGING to intercept window state changes

The message is sent early in the window state changing process, unlike , which tells you about what already happened. A crucial difference (aside from the timing) is that you can influence the state change by handling the message and modifying the structure. Here's an example that prevents the window from being resized. Before the ...

Use WM_WINDOWPOSCHANGED to react to window state changes

The documentation for the message points out that the message is not sent under certain circumstances. But what if you want to know when the window is shown, including in the cases where you don't get ? The message is sent at the end of the window state change process. It sort of combines the other state change notifications, , , and . ...

Generating initials from a name is trickier than you think

Even though I'm signed in, the page claims that anonymous comments are not allowed, so I'm reduced to posting my comment here and generating a trackback. Some time ago, Robert McLaws wrote a function that generates initials from a name. Let's set aside completely the issue of non-U.S. names; the function doesn't even handle U.S. names ...

Taxes: Files larger than 4GB

Nowadays, a hard drive less than 20 gigabytes is laughably small, but it used to be that the capacity of a hard drive was measured in megabytes, not gigabytes. Today, video files and databases can run to multiple gigabytes in size, and your programs need be prepared for them. This means that you need to use 64-bit file offsets such as those ...