Showing tag results for Code

Feb 3, 2014
Post comments count0
Post likes count1

How can I make a WNDPROC or DLGPROC a member of my C++ class?

Raymond Chen
Raymond Chen

Continuing my discussion of How can I make a callback function a member of my C++ class? Common special cases for wanting to use a member function as a callback function are the window procedure and its cousin the dialog procedure. The question, then, is where to put the reference data. Let's start with window procedures. The function and it...

Code
Jan 31, 2014
Post comments count0
Post likes count1

Non-psychic debugging: If somebody's complaining that a collection should be empty but isn't, you might want to see what's in there

Raymond Chen
Raymond Chen

A programmer on the GHI team (yes, the same GHI team) reported that they were hitting an assertion failure using an internal library and asked for help debugging it. "Can somebody help me figure out which factory it is that did not get unregistered?" I didn't work on this internal library, but on the other hand I'm not afraid to look inside....

Code
Jan 30, 2014
Post comments count0
Post likes count1

Can process IDs be greater than 64000? Because we're seeing process IDs greater than 64000

Raymond Chen
Raymond Chen

A customer asked what to me was a very strange question. Can process IDs be greater than 64000? Because we're seeing process IDs greater than 64000. This is a strange question because the answer is right there: You're seeing process IDs greater than 64000 with your very own eyes. Do you doubt the evidence right there in front of you? It's li...

Code
Jan 29, 2014
Post comments count0
Post likes count1

One of my favorite error codes: Optional parameter missing

Raymond Chen
Raymond Chen

The error Optional parameter missing sounds awfully paradoxical, doesn't it. I mean, if the parameter is optional, why are you complaining that it's missing? This KB article explains why, specifically, the part that says, "If a parameter is omitted, the calling program must…". For those who don't want to click through, here's the deal: Me...

Code
Jan 27, 2014
Post comments count0
Post likes count1

How can I make a callback function a member of my C++ class?

Raymond Chen
Raymond Chen

Instead of a Little Program today, I'm going to answer a Little Question. This is a common beginner question, but I figure I'll just spell it out right here for posterity. First of all, you probably noticed that you can't do this: That's because the is declared as a so-called free function, but member functions are not free. Neither are func...

Code
Jan 24, 2014
Post comments count0
Post likes count1

Non-psychic debugging: Looking for leaked objects by their vtable

Raymond Chen
Raymond Chen

A programmer on the GHI team reported that they were hitting an assertion failure using an internal library and asked for help debugging it. I didn't work on this internal library, but on the other hand I'm also not afraid to look inside and around. The assertion failure said, "Assertion failed: All widgets from a factory must be destroyed be...

Code
Jan 22, 2014
Post comments count0
Post likes count1

What clock do MSG.time and GetMessageTime use?

Raymond Chen
Raymond Chen

The structure has a field called which is a . There is also a function which returns a . Both are documented as returning the time the message was generated, but the types are different. Are these time units comparable? Yes, they are the same thing. They all use the 32-bit timer provided by the function. Sorry about the inconsistency in sign...

Code
Jan 17, 2014
Post comments count0
Post likes count1

Psychic debugging: Why messages aren't getting processed by your message pump

Raymond Chen
Raymond Chen

The second parameter to the is an optional window handle that is used to tell the function to retrieve only messages that belong to the specified window. A filtered is nearly always a bad idea, because your program will not respond to messages that don't meet the filter. Unlike a filtered (which simply returns "no messages satisfy the filter...

Code