The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
Manipulating the DIB color table for fun and profit
If you create a DIB section at 8bpp or lower, then it will come with a color table. Pixels in the bitmap are represented not by their red/blue/green component values, but are instead indices into the color table. For example, a 4bpp DIB section can have up to sixteen colors in its color table. Although displays that use 8bpp or lower are considered woefully outdated nowadays, bitmaps in that format are actually quite useful precisely due to the fact that you can manipulate colors in the bitmap, not by manipulating the bits themselves, but instead by manipulating the color table. Let's demonstrate this by tak...
Keeping classic hardware alive through emulation
At the Windows 2000 Conference and Expo which coincided with the operating system's launch, I paid a visit to the emulators.com booth, where they were excitedly showing off SoftMac 2000, a Mac emulator that ran on Windows 2000. Emulator trivia: MacOS booted in five seconds under Windows 2000, which was faster than the real Mac, because the emulator simulated a 1GB Mac so the Mac memory manager never had to do any paging. Now, the host computer didn't have 1GB of real RAM, so the host computer was still paging, but it turns out that you're better off letting the Windows 2000 kernel do the ...
Blitting between color and monochrome DCs
When blitting between color and monochrome DCs, The text foreground and background colors play a role. We saw earlier that when blitting from a monochrome DC to a color DC, the color black in the source turns into the destination's text color, and the color white in the source turns into the destination's background color. This came in handy when we wanted to colorize a monochrome bitmap. This trick works in reverse, too. If you blit from a color DC to a monochrome DC, then all pixels in the source that are equal to the background color will turn white, and all other pixels will turn black. In other words, GD...
New dessert lounge: Coco la ti da
After a Seattle Symphony concert, it has long been a tradition among my friends to walk the three blocks from Benaroya Hall, up University Street, past Luly Yang Couture to gawk at the jaw-dropping gowns in the window (the pictures on the web site fail to capture their fabulousness), arriving at the W Hotel, home of Earth & Ocean, where we would settle ourselves in for a post-concert dessert. The desserts themselves were exquisite, thanks to the inspiration of Seattle's "diva of desserts", Sue McCown. Or at least, that was our routine until this season. Sue McCown left Earth & Ocean during the summ...
What do bitwise operations mean for colors?
Someday, you're going to pass a raster operation to the function that entails bit manipulation. Something like perhaps, or possibly the dreaded . These bitwise operations make perfect sense for monochrome bitmaps, since those are one bit per pixel anyway. But what does it mean for color bitmaps? What do you get when you "and" together forest green (#228B22) and hot pink (#FF69B4)? The bitwise operations are performed in the pixel space of the destination. If the destination is a non-palettized bitmap format (higher than 8bpp), then the pixel values are red, blue and green components packed together (in various...
Converting an HRESULT to a Win32 error code: Diagram and answer to exercise
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 mapping of all the positive values, mod 65536, into the range 0x80070000 through 0x8007FFFF. Now let's take a look at that puzzle I left behind: Sometimes, when I import data from a scanner, I get the error "The directory cannot be removed." What does this mean? My ps...
A modest proposal: Solving the problem of steroids in baseball
In recent years, the issue of steroids in baseball has been the source of much hand-wringing. Some people argue that steroids are ruining the game. Others say that you can't go around trampling the Bill of Rights and punishing people for doing things that are perfectly legal anyway. To resolve this issue, I present this modest proposal. Today, Major League Baseball is divided into two leagues, the National League and the American League, which, aside from the designated hitter rule, are pretty much indistinguishable. (There are other minor rule differences, such as the one regarding batting helmets, 1.16(b...
Why can't you use the Tab key to select items from the auto-complete drop-down?
An anonymous commenter asked why the Tab key doesn't select items from the auto-complete drop-down list. The answer: Because that key already has some other meaning. The Tab key is used to navigate among controls in a dialog box. Adding auto-complete behavior to an existing dialog would disturb the tab order, which would in turn frustrate people who had "muscle-memorized" their way through the system. Instead of, "Ctrl+O text Tab Space Enter", it's "Ctrl+O text ... um... try to get the auto-complete drop-down to go away so the Tab key will take you to the next radio button, then hit Tab, Space, Enter." If the ...
How do I test that return value of ShellExecute against 32?
It doesn't matter, as long as you do it.