The Old New Thing

Drawing a monochrome bitmap with transparency

Last time, I left you with a brief puzzle. Here are two approaches. I am not a GDI expert, so there may be even better solutions out there. To emphasize the transparency, I'll change the window background color to the application workspace color. BOOL WinRegisterClass(WNDCLASS *pwc) { pwc->hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE...

Rendering menu glyphs is slightly trickier

Last time, we saw how to draw themed and unthemed radio buttons, and I mentioned that menu glyphs are trickier. They're trickier because they are provided as raw monochrome bitmaps instead of fully-formed color-coordinated bitmaps. First, let's do it wrong in order to see what we get. Then we'll try to fix it. Start with a clean new scratch...

Rendering standard Windows elements

The DrawFrameControl function allows you to render standard Windows elements in your custom controls. Let's start by simply rendering a selected radio button. Start with our new scratch program and make this very simple change: class RootWindow : public Window { ... protected: void PaintContent(PAINTSTRUCT *pps); ... }; void ...

When the normal window destruction messages are thrown for a loop

Last time, I alluded to weirdness that can result in the normal cycle of destruction messages being thrown out of kilter. Commenter Adrian noted that the WM_GETMINMAXINFO message arrives before WM_NCCREATE for top-level windows. This is indeed unfortunate but (mistake or not) it's been that way for over a decade and changing it now would ...

What is the difference between WM_DESTROY and WM_NCDESTROY?

There are two window messages closely-associated with window destruction, the WM_DESTROY message and the WM_NCDESTROY message. What's the difference? The difference is that the WM_DESTROY message is sent at the start of the window destruction sequence, whereas the WM_NCDESTROY message is sent at the end. This is an important distinction ...

FindFirstFile is not a SQL query

The function is not a SQL query. It's a very simple directory enumerator. There is a slightly fancier version called , but even that function doesn't add much at present beyond filtering for directories or devices. You don't get to pass it sort criteria like or "return the files/directories sorted smallest file first", or "return the ...