The Old New Thing

It's not a good idea to give multiple controls on a dialog box the same ID

When you build a dialog, either from a template or by explicitly calling , one of the pieces of information about each control is a child window identifier. And it's probably in your best interest to make sure two controls on the dialog don't have the same ID number. Of course, one consequence of giving two control the same ID number is that...

Eventually the window manager simply says that enough is enough

Many window manager operations are recursive, and eventually the window manager will simply say that enough is enough when the recursion goes too deep. We've seen this when you nest windows more than 50 levels deep or nest menus more than 25 levels deep, for example. (Note also that these limits may change in the future, so don't rely on ...

Why does PrintWindow hate CS_PARENTDC? Because EVERYBODY hates CS_PARENTDC!

Commenter kero wants to know why the function hates . (And , and .) Because everybody hates ! (And , and .) We saw earlier that these class styles violate widely-held assumptions about how drawing works. I mean, who would have thought that asking for two device contexts would give you the same one back twice? Or that changes to one device...

How do I prefetch data into my memory-mapped file?

A customer created a memory mapping on a large file and found that when the memory manager wanted to page in data from that file, it did so in 32KB chunks. The customer wanted to know if there was a way to increase the chunk size for efficiency. The memory manager decides the chunk size for memory-mapped files, and the chunk size is currently...

What happens if I call KillTimer with a NULL hwnd?

A customer discovered a bug in their code and wanted some information on how serious it was, so they could assess how urgently they need to issue a fix. We have code that calls with a valid window handle, but then we destroy the window before we get around to calling . When we finally do call , we do so with a window handle. The calls are ...

If my window hosts multiple windowless ActiveX controls, which one do I call IOleInPlaceActiveObject::TranslateAccelerator and IOleInPlaceObjectWindowless::OnWindowMessage on?

Commenter Farproc asks how one goes about hosting two windowless ActiveX controls in a single window. In particular, "none of the documentation explains how to choose which control to send and on?" Actually, the documentation does say. The documentation for says, "Active in-place objects must always be given the first chance at ...