The Old New Thing

How do I find out what size the window manager would have chosen for my window?

We saw some time ago how the window manager decides where to place a newly-created window if you pass the values when creating the window. But what if you want to filter the values first? If you pass an explicit upper left corner but pass for the width and height, then the bottom right corner will be down near the bottom right corner of the...

Using the TAB key to navigate in non-dialogs, redux

You want to use the TAB key to navigate through a non-dialog, so you call in your message loop, but it doesn't work! The problem here is that you are passing the wrong window handle to . The first parameter to is the dialog-like window you want to be able to navigate through. But the code above passes the window that received the ...

I wrote my thesis on an airplane, for heaven's sake

As I wrote today's story, I recalled that I wrote the bulk of my thesis on an airplane. In longhand. Microsoft flew me out for an interview, so I had to endure two cross-country plane trips. I scheduled the interview on a Monday so that I would miss only one day of class, and among the things I brought with me was a notepad, which started ...

I wrote FAT on an airplane, for heaven’s sake

When you wrote code for 16-bit Windows, one of the things you spent time doing as part of performance tuning was deciding which functions should be grouped together in which segments. Code in 16-bit Windows executed out of code segments, each of which could be up to 64KB in size. When a code segment was loaded from disk, the entire segment ...

But instead, they decided to build the Great Wheel

I dreamed that Seattle was building its own version of the Eiffel Tower. Just like the original, except that it was also a thrill ride similar to Round Up but you are seated. It turns out that the city of Seattle accepted my subconscious's instructions to replicate another city's famous landmark, but the message wasn't received loud and ...

Printing the contents of the clipboard as text to stdout

The takes its stdin and puts it on the clipboard. But how do you get it out? That's today's Little Program. (I guess we could call it .) Okay, what do we have here? We open the clipboard and try to get the Unicode text on it. We then look for the null terminator within the first 0x10000000 bytes. Why do I stop at 256MB? Because I'm lazy...

What's the difference between CopyIcon and DuplicateIcon?

There are two functions that can be used to create one icon that is identical to another. One of them is . The other is . What's the difference? There isn't any difference. Both functions clone an icon. In fact, their implementations are basically line-for-line identical. Originally, there was just one function to clone an icon: . Windows&...

The management of memory for resources in 16-bit Windows, redux

Some time ago, I briefly ran down how 16-bit Windows managed memory for resources. But there's a detail that I neglected to mention: Ownership. As we saw, a resource handle was really a pointer to the resource directory entry of the resource from the corresponding module. This could be done with a 16-bit pointer because the segment portion ...