The Old New Thing

How do the common controls convert between ANSI and Unicode?

Commenter Chris Becke asks how the common controls convert ANSI parameters to Unicode, since the common controls are Unicode internally. Everything goes through , pretty much by definition. The ANSI code page is . That's what ACP stands for, after all. Now, there are some function families that do not use ANSI. The console subsystem, for ...

Why are DLLs uninitialized in the "wrong" order?

This is really just a corollary to Why are DLLs unloaded in the "wrong" order. Exactly the same logic that explains why DLLs are unloaded in the "wrong" order also explains why they are uninitialized in the "wrong" order. Once you understand the first issue, the second comes for free; just change to in your analysis. Apply the logic to ...

Why does OpenProcess succeed even when I add three to the process ID?

A customer noticed that if you add three to a process ID and pass it to the function, it still succeeds. Why is that? Well, first of all, I need to say up front that the behavior you're seeing is an artifact of the implementation and is not part of the contract. You're passing intentionally invalid parameters, what did you expect? The ...

Why are accelerators for hidden controls still active?

In the suggestion box, Serge Wautier asked why accelerators for hidden controls remain active. He's apparently rather insistent because he asked the question again a few months later. Asking the same question multiple times reduces the likelihood that I'll answer it. Consider yourself lucky that I wrote this answer before I noticed the ...

You can't give away something that isn't yours

This rule of real life applies to code as well. If something doesn't belong to you, then you can't give it away. For example, functions like and take ownership of the item that you pass it. In SetClipboardData's case, the memory block you pass as the parameter becomes the property of the clipboard. For it's the that becomes the ...

What does TranslateAccelerator do?

For some reason, there appears to be some confusion over what does. It's very simple, and it's all spelled out in the documentation. You give it a message, and if the message is a keypress that matches an entry in the accelerator table, the corresponding or message is sent to the window you said you are translating messages for. One ...

How do I flash my window caption and taskbar button manually?

Commenter Jonathan Scheepers wonders about those programs that flash their taskbar button indefinitely, overriding the default flash count set by . The function and its simpler precursor let a program flash its window caption and taskbar button manually. The window manager flashes the caption automatically (and Explorer follows the ...