Showing tag results for Code

Nov 10, 2006
Post comments count0
Post likes count0

Converting an HRESULT to a Win32 error code: Diagram and answer to exercise

Raymond Chen
Raymond Chen

Here's the diagram from How do I convert an HRESULT to a Win32 error code?. If you are offended by VML, cover your ears and hum for a while. The little sliver at the top is the mapping of zero to zero. The big white box at the bottom is the mapping of all negative numbers to corresponding negative numbers. And the rainbow represents the mapp...

Code
Nov 3, 2006
Post comments count0
Post likes count3

How do I convert an HRESULT to a Win32 error code?

Raymond Chen
Raymond Chen

Everybody knows that you can use the macro to convert a Win32 error code to an , but how do you do the reverse? Let's look at the definition of : If the value is less than or equal to zero, then the macro returns the value unchanged. Otherwise, it takes the lower sixteen bits and combines them with and . How do you reverse this process? H...

Code
Nov 2, 2006
Post comments count0
Post likes count0

Make sure you disable the correct window for modal UI

Raymond Chen
Raymond Chen

Some time ago, I was asked to look at two independent problems with people trying to do modal UI manually. Well, actually, when the issues were presented to me, they weren't described in quite that way. They were more along the lines of, "Something strange is happening in our UI. Can you help?" Only in the discussion of the scenarios did it become...

Code
Oct 23, 2006
Post comments count0
Post likes count1

Psychic debugging: Why doesn't my program show up when I call ShellExecute?

Raymond Chen
Raymond Chen

This question came in from a customer (paraphrased): If I run my program from the command prompt, it works great, but if I run it from my launcher via , it never appears. See how good your psychic powers are at solving this problem before I give you the second question that gives away the answer. Any luck? Here's a second question from a d...

Code
Oct 19, 2006
Post comments count0
Post likes count0

No good deed goes unpunished, part 2

Raymond Chen
Raymond Chen

Sometimes you're better off keeping your fool mouth shut. When I reply to a question on an internal discussion list, often with a clarifying question rather than an answer, it will occasionally happen that the person I replied to will send a response directly to me rather than including the discussion list. This is bad for a few reasons. When ...

CodeemailNo good deed goes unpunished
Oct 17, 2006
Post comments count0
Post likes count0

What does the letter "T" in LPTSTR stand for?

Raymond Chen
Raymond Chen

The "T" in comes from the "T" in . I don't know for certain, but it seems pretty likely that it stands for "text". By comparison, the "W" in probably comes from the C language standard, where it stands for "wide".

Code
Oct 12, 2006
Post comments count0
Post likes count0

How do I prevent multi-line edit controls from eating the Enter key?

Raymond Chen
Raymond Chen

You might decide to put a multi-line edit control in a dialog box, not because you want the user to input multi-line data, but because it's a convenient way to display multi-line text. When you do that, you may notice that the Enter key does not invoke the default dialog button, as you might normally expect. That's because the multi-line edit contr...

Code
Oct 10, 2006
Post comments count0
Post likes count0

When something is available for the user, which user are we talking about?

Raymond Chen
Raymond Chen

Some people have taken issue with the term for the name of the base of the message range that is the province of the window class implementor. (Refresher for those who forget which messages belong to whom.) The complaint is that the user can't use them since they belong to the window class. Aha, but the real question is, "Who is the user?" In oth...

Code
Oct 6, 2006
Post comments count0
Post likes count0

A very brief return to part 6 of Loading the Chinese/English dictionary

Raymond Chen
Raymond Chen

Back in Part 6 of the first phase of the "Chinese/English dictionary" series (a series which I intend to get back to someday but somehow that day never arrives), I left an exercise related to the member of the union. Alignment is one of those issues that people who grew up with a forgiving processor architecture tend to ignore. In this case,...

Code