Showing tag results for Code

Jul 25, 2008
Post comments count0
Post likes count1

Simulating a drop, part two

Raymond Chen

Last time, we wrote a tiny program to simulate dropping a file on another file, but we discovered that it didn't work for dropping a file onto Mail Recipient.MAPIMail. The reason, as you no doubt instantly recognized, is that the MAPIMail handler creates a worker thread, and we're exiting the process before the worker thread has finished its work....

Code
Jul 24, 2008
Post comments count0
Post likes count1

Reading a contract from the other side: Simulating a drop

Raymond Chen

Most people, when they think of the IDropTarget interface, think only of implementing a drop target. But you can read the contract from the other side, because the description of how a drag source interacts with a drop target tells you how to be a drag source. To summarize, the sequence of drop target operations go like this: IDropTarget::Drag...

Code
Jul 23, 2008
Post comments count0
Post likes count1

Theorize if you want, but if the problem is right there in front of you, why not go for the facts?

Raymond Chen

On an internal discussion list, somebody asked a question similar to this: My program launches a helper program. This helper program does different things based on the command line parameters, but the way I'm using it, it just prints its results to the console and exits. When I launch this program and wait for it to exit, my wait never completes....

Code
Jul 21, 2008
Post comments count0
Post likes count1

MessageBoxIndirect loads the icon itself; you can’t hand it a pre-loaded icon

Raymond Chen

Commenter 8 wants to know how to tell the function to use an existing instead of pointing it to an icon resource. You can't. The loads the icon itself. You can't hand it a pre-loaded icon. Of course, it's hardly rocket science to write your own function that lets you use whatever icon you want. There's no law that says all Yes/No dialo...

Code
Jul 3, 2008
Post comments count0
Post likes count1

How did the invalid floating point operand exception get raised when I disabled it?

Raymond Chen

Last time, we learned about the dangers of uninitialized floating point variables but left with a puzzle: Why wasn't this caught during internal testing? I dropped a hint when I described how s work: You have to ask the processor to raise an exception when it encounters a signaling NaN, and the program disabled that exception. Why was an excepti...

Code
Jul 2, 2008
Post comments count0
Post likes count1

Uninitialized floating point variables can be deadly

Raymond Chen

A colleague of mine related to me this story about uninitialized floating point variables. He had a function that went something like this, simplified for expository purposes. The infoType parameter specified which piece of information you're requesting, and depending on what you're asking for, one or the other of the output parameters may not con...

Code
Jun 23, 2008
Post comments count0
Post likes count1

Just because you're using a smart pointer class doesn't mean you can abdicate understanding what it does

Raymond Chen

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...

Code
Jun 16, 2008
Post comments count0
Post likes count1

How do the common controls convert between ANSI and Unicode?

Raymond Chen

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...

Code
Jun 11, 2008
Post comments count0
Post likes count1

If you say that you don't care about something, you shouldn't be upset that it contains garbage

Raymond Chen

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...

Code