The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

A cache with a bad policy is another name for a memory leak
May 2, 2006
0
0

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 motivated by an actual problem the Windows performance team researched. Consider a cache of variable-sized buffers. I will use only a one-entry cache for simplicity. In real life, the cache would be more complicated: People tend to have a deeper cache of four to ten entries...

Tips from an American on on driving in Taiwan
May 1, 2006
0
0

Tips from an American on on driving in Taiwan

Raymond Chen
Raymond Chen

Although I have been a passenger in a car many times, I thank my lucky stars that I have never had to be the person behind the wheel in Taiwan. But if you decide you want to give it a shot, you might want to pick up some driving tips from an American who spent time in Taiwan as an English teacher, part of his Teaching English in Taiwan site. My conclusion is simply that one should merely avoid driving entirely. The text is largely disconnected from the pictures, but that's okay. The pictures just bring back memories of Taiwan in both its scenic and not-so-scenic glory. In the section on learning Chinese, he...

What's so special about bitmaps and DCs?
May 1, 2006
0
1

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 it. Selecting a bitmap into multiple DCs means that writing to the bitmap from one DC secretly changes it in another, which isn't a very nice thing to do to a DC. So let's see, you can select pens, brushes, and fonts into multiple DCs, but you can't do it with bitmaps....

Grace period for Swedish currency conversion extended to the end of the year
Apr 28, 2006
0
0

Grace period for Swedish currency conversion extended to the end of the year

Raymond Chen
Raymond Chen

Like the United States, Sweden is in the process of upgrading their paper currency to incorporate new security measures. Unlike the United States, Sweden is declaring the old bills no longer valid. The original plan was that the old 20-kronor, 100-kronor and 500-kronor notes would expire today, but due to the enormous number of outstanding old bills (1.5 billion kronor, by Riksbanken's estimation), the grace period for turning in your old notes has been extended to the end of the year. The expiration date for the silver 50-öre coin has not changed, however. Today is still the last day those coins are legal...

What does CS_SAVEBITS do?
Apr 28, 2006
0
0

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 the window will be displayed. First, it asks the video card to store the pixels in available off-screen video memory (fast). If no video memory is available, then the pixels will be stored in system memory (slower). If the saved pixels have not been discarded in the mea...

A new scripting language doesn't solve everything
Apr 27, 2006
0
0

A new scripting language doesn't solve everything

Raymond Chen
Raymond Chen

Yes, there are plenty of scripting languages that are much better than boring old batch. Batch files were definitely a huge improvement over back in 1981, but they've been showing their age for quite some time. The advanced age of boring old batch, on the other hand, means that you have millions of batch files out there that you had better not break if you know what's good for you. (Sure, in retrospect, you might decide to call the batch language a design mistake, but remember that it had to run in 64KB of memory on a 4.77MHz machine while still remaining compatible in spirit with CP/M.) Shipping a new comm...

No good deed goes unpunished: Bug assignment
Apr 26, 2006
0
1

No good deed goes unpunished: Bug assignment

Raymond Chen
Raymond Chen

Sometimes you're better off keeping your fool mouth shut. The other day I got a piece of email requesting that I look at a crashed system because the tester believed it was another instance of bug 12345. While that may very well have been the case, bug 12345 was a kernel pool corruption bug in the object manager, something of which I know next to nothing. Why was I being asked to look at the machine? Because the bug was originally assigned to my team. As a gesture of good will, I reassigned the bug to a more appropriate team, and that was my downfall, because that put my fingerprint on the bug report....

Correctly spell xerophthalmia and the crowd goes wild
Apr 25, 2006
0
0

Correctly spell xerophthalmia and the crowd goes wild

Raymond Chen
Raymond Chen

One of the things I did in San Francisco was attend a performance of The 25th Annual Putnam County Spelling Bee. I went into the show with some trepidation, fearing that it would recall painful memories from my own career on the spelling bee circuit as a middle-schooler. Fortunately, my experience as a spelling bee participant only served to make the show more enjoyable. Each performance is different because four volunteers from the audience are invited to join the six student characters on the stage to participate in the bee. Things got off to an unexpected start when the first audience member misspelled "Mex...

No, really, you need to pass all unhandled messages to DefWindowProc
Apr 25, 2006
0
0

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 processing in . Yet, every so often, I run into another program that assumed that "Microsoft will never enhance the window manager" and simply returned zero for all the messages they didn't handle. Indeed, often these programs don't even cover all the existing messages! One...