The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Jul 21, 2009
Post comments count 0
Post likes count 1

Proto-Microspeak: Coceptualize

Raymond Chen

Many years ago, to see whether anybody was paying attention, a colleague and I slipped the made-up word "coceptualize" into a document. Nobody said a thing. Either nobody read that part of the document, or they did and thought it was a real word.

Jul 20, 2009
Post comments count 0
Post likes count 1

Why was MoveTo replaced with MoveToEx?

Raymond Chen

Commenter Ulric asks, "Where did MoveTo(HDC, int, int) go?" Back in the 16-bit days, the function to move the current point was called , and its return value was a which encoded the previous position, packing two 16-bit coordinates into a single 32-bit value. As part of the transition to 32-bit Windows, GDI switched to using 32-bit coordinates instead of the wimpy 16-bit coordinates of old. As a result, it was no longer possible to encode the original position in a single . Something new had to be developed. That new thing was the function. Instead of returning a single , it accepted a final parameter whic...

Jul 17, 2009
Post comments count 0
Post likes count 0

The disembodiment of DIBs from the DIB section

Raymond Chen

So far this week, we've separated the DIB metadata () from the pixels of a DIB section. But there's really no need for the DIB section at all! As long as you have the pixels and the metadata, you can draw bits. We demonstrate this by drawing a rather stupid-looking bitmap onto the screen, but doing so without the use of s at all! Start with a brand new scratch program and make these changes: We are drawing a bitmap without using an ! The technique is the same one we've been using all week: Building a and using it to guide the interpretation of a chunk of memory containing pixels. Just to make things eas...

Jul 16, 2009
Post comments count 0
Post likes count 0

Caption contest: The pinball machine: Results

Raymond Chen

It's been quite a while, but a winner in the caption contest has been selected and the prize finally reached its destination. (Mostly due to procrastination on my part. Don't blame the postal service.) The winner is Scott from Australia with his entry Only 5,000 more referrals until MULTIBALL Even though it's kind of low-brow, it made me laugh spontaneously. For his efforts, Scott wins a deluxe prize package consisting of Here's Scott's acceptance speech: I'd like to thank all the letters that made the caption possible - the O, the N, the R, and especially the L - that little guy r...

Jul 16, 2009
Post comments count 0
Post likes count 0

Separating the metadata from the DIB pixels: Changing the raster operation

Raymond Chen

For a few days now, we've used the function in conjunction with a precomputed to draw a DIB with an alternate color table without modifying the . The function operates like a with raster operation . If you want another raster operation, you can use , which has a final raster operation parameter. Despite its name, you don't have to stretch with . Just pass a source and destination of equal size, and you've performed a NOP stretch, but you get the benefit of the raster operation. I changed the call from to , setting the source and destination rectangles to the same size (so no actual stretching occurs),...

Jul 15, 2009
Post comments count 0
Post likes count 0

On gender differences in expectations of thinness, and the impact on guys who live in their parents' basement

Raymond Chen

At dinner a few years ago, one of my friends brought up a study (which I can't find, so who knows if it's actually true, but let's assume it's true for the sake of the story) that examined the effect of gender differences in expectations of thinness. One of the factors that the study considered was sexual orientation, and they found that homosexual men were, on average, thinner than their heterosexual brethren, and conversely that heterosexual women were thinner on average than their homosexual um, what's the female counterpart to "brethren"? In other words, the conclusion of the study was that the pressure to b...

Jul 15, 2009
Post comments count 0
Post likes count 0

Separating the metadata from the DIB pixels: Precalculating the BITMAPINFO

Raymond Chen

Last time, we saw that you can use the function to draw a DIB with an alternate color table without having to modify the . In that version of the function, we selected the into a device context in preparation for drawing from it, but in fact that step isn't necessary for drawing. It was merely necessary to get the original color table so we could build our grayscale color table. If you don't care what the original colors are, then you can skip that step. And even if you care what the old colors are, and if you assume that the colors don't change, then you only need to ask once. To demonstrate, that all the ...

Jul 14, 2009
Post comments count 0
Post likes count 0

What happens to your restaurant tip?

Raymond Chen

Some time ago, the Seattle Times ran an article on how your restaurant tip gets divided up among the staff. A week later, they ran an entire article of responses to the original article, some from customers, but many from restaurant staff (both cooks and servers). And, now on a roll, the next week's food section looked at the sociology of splitting the bill with a sidebar looking at how hard it is for different types of restaurants.

Jul 14, 2009
Post comments count 0
Post likes count 0

The fun and profit of manipulating the DIB color table can be done without having to modify it

Raymond Chen

If I were Michael Kaplan, I'd have a more clever title like I'm not touching you! or Look but don't touch or maybe Looking at a DIB through -colored glasses. We saw some time ago that you can manipulate the DIB color table to perform wholesale color remapping. But in fact you can do this even without modifying the DIB color table, which is a handy trick if you want to do color remapping but you don't want to change the bitmap itself. For example, the bitmap is not one that is under your control (so you shouldn't be modifying it), or the bitmap might be in use on multiple threads (so modifying it will result ...