It's great when you have a tool to make programming easier,
but you still must understand what it does or you're
just replacing one set of problems with another set of more subtle
problems.
For example, we discussed earlier the importance of knowing
when your destructor runs.
Here's another example, courtesy of my colleague Chris Ashton.
This was...
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 example...
There are many situations where you pass a structure to a function,
and the function fills in the structure with information you request.
In some cases, the function always fills in the entire structure
(example: ).
In other cases, you tell the function
which bits of information you care about,
to save the function the effort of computing somethin...
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 the sc...
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 context of...
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 duplicate...
Shell extensions that create worker threads need to call the
function
so that Explorer will not exit while the worker thread is still running.
When your worker thread finishes, you release the
that you obtained to tell the host program,
"Okay, I'm done now, thanks for waiting."
You can read this contract from the other side.
Instead of thinkin...
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 property of ...
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 point of...