Showing tag results for Code

May 16, 2006
Post comments count0
Post likes count0

The real scoop on the the x64 calling convention on 64-bit Windows

Raymond Chen
Raymond Chen

Official (though preliminary) documentation on the x64 calling convention is available on MSDN, for those who want more than my quack overview. (Oops, I meant "quick overview". Little Freudian slip there.)

Code
May 3, 2006
Post comments count0
Post likes count0

The alertable wait is the non-GUI analog to pumping messages

Raymond Chen
Raymond Chen

When you are doing GUI programming, you well know that the message pump is the primary way of receiving and dispatching messages. The non-GUI analog to the message pump is the alertable wait. A user-mode APC is a request for a function to run on a thread in user mode. You can explicitly queue an APC to a thread with the function, or you can do ...

Code
May 2, 2006
Post comments count0
Post likes count1

A cache with a bad policy is another name for a memory leak

Raymond Chen
Raymond Chen

A common performance trick is to reduce time spent in the heap manager by caching the last item freed (or maybe the last few) so that a subsequent allocation can just re-use the item rather than having to go make a new one. But you need to be careful how you do this or you can end up making things worse rather than better. Here's an example motiva...

Code
May 1, 2006
Post comments count0
Post likes count1

What's so special about bitmaps and DCs?

Raymond Chen
Raymond Chen

You can select pens, brushes, fonts and bitmaps into a DC with the function, and from this list, bitmaps are special. Because, if you look carefully, bitmaps are the only modifiable objects on the list. Pens, brushes and fonts cannot be modified once they are created. But bitmaps, oh, bitmaps. A bitmap selected into a DC changes as you draw into ...

Code
Apr 28, 2006
Post comments count0
Post likes count0

What does CS_SAVEBITS do?

Raymond Chen
Raymond Chen

If you specify the class style, then the window manager will try to save the bits covered by the window. But the real question is why, because that is your guide to using this power only for good, not for evil. When a window whose class specifies the class style is displayed, the window manager takes a snapshot of the pixels on the screen where ...

Code
Apr 25, 2006
Post comments count0
Post likes count0

No, really, you need to pass all unhandled messages to DefWindowProc

Raymond Chen
Raymond Chen

Earlier I had discussed that you have to return the special value if you want to deny a device removal query because too many programs thought that they had covered "all" the Windows messages and just returned zero for the others. Since then, there have been lots of other window messages added to the system, many of which contain nontrivial proce...

Code
Apr 18, 2006
Post comments count0
Post likes count0

How to fill in that number grouping member of NUMBERFMT

Raymond Chen
Raymond Chen

If you look at the structure, the way groups are expressed by the member do not match the value returned by : expresses grouping as a series of semicolon-separated numbers, each expressing the number of digits in each group (least-significant group first). A trailing zero indicates that the last grouping should be repeated indefinitely. For ex...

Code
Apr 17, 2006
Post comments count0
Post likes count0

Locale-sensitive number grouping

Raymond Chen
Raymond Chen

Most westerners are familiar with the fact that the way numbers are formatted differ between the United States and much of Europe. What people don't realize is that the grouping is not always in threes. In India, the least significant group consists of three digits, but subsequent groups are in pairs. I've also seen reports that the first group...

Code
Mar 29, 2006
Post comments count0
Post likes count0

Inadvertently passing large objects by value

Raymond Chen
Raymond Chen

One mark of punctuation can make all the difference. One program was encountering a stack overflow exception in a function that didn't appear to be doing anything particularly stack-hungry. The following code illustrates the problem: (In reality, the algorithm for comparing two tests results was much more complicated, but that's irrelevant to...

Code
Mar 27, 2006
Post comments count0
Post likes count0

Why doesn't the window manager just take over behavior that used to be within the application's purview?

Raymond Chen
Raymond Chen

A commenter named "Al" wondered why the window manager couldn't just take over behavior that used to be within the application's purview, such as painting the non-client area, in order to avoid problems with applications not responding to messages promptly enough. If the window manager were being rewritten, then perhaps it could. But to do it now ...

Code