Showing tag results for Code

Aug 11, 2005
Post comments count0
Post likes count0

Adding a lookup control to the dictionary: Just getting it on the screen

Raymond Chen
Raymond Chen

When we last left the dictionary project, we were able to display the dictionary entries but hadn't yet gotten around to searching it. Today, we'll place the lookup control, though we won't hook it up until next time. First, we give the edit control an ID and create some member variables to keep track of it. class RootWindow : public Window { ...

Code
Aug 9, 2005
Post comments count0
Post likes count0

The dangers of messing with activation when handling a WM_ACTIVATE message

Raymond Chen
Raymond Chen

This is basically the same thing as The dangers of playing focus games when handling a WM_KILLFOCUS message, just with activation in place of focus. One developer discovered the hard way that if you mess with activation inside your WM_ACTIVATE handler, things get weird. The author noted that if he posted a message and did the work from the posted...

Code
Aug 8, 2005
Post comments count0
Post likes count0

The dangers of playing focus games when handling a WM_KILLFOCUS message

Raymond Chen
Raymond Chen

I had noted last year that WM_KILLFOCUS is the wrong time to do field validation. Here's another example of how messing with the focus during a WM_KILLFOCUS message can create confusion. Consider an edit control that displays feedback via a balloon tip. For example, password edit controls often warn you if you're typing your password while Caps...

Code
Aug 5, 2005
Post comments count0
Post likes count0

Why does the Internet Explorer animated logo arrange its frame vertically?

Raymond Chen
Raymond Chen

If you ever tried to build a custom animated logo for Internet Explorer, you cetainly noticed that the frames of the animation are arranged vertically rather than horizontally. Why is that? Because it's much more efficient. Recall that bitmaps are stored as a series of rows of pixels. In other words, if you number the pixels of a bitmap like ...

Code
Aug 4, 2005
Post comments count0
Post likes count0

Double-clicking radio buttons

Raymond Chen
Raymond Chen

A subtlety that adds a level of polish to your dialogs is supporting double-clicked radio buttons as an abbreviation for "select + OK". (Or "select + Next" or "select + Finish" if the page is part of a wizard.) Consider the following dialog template and associated dialog procedure: 1 DIALOGEX DISCARDABLE 32, 32, 200, 76 STYLE DS_MODALFRAME | ...

Code
Aug 3, 2005
Post comments count0
Post likes count0

Drawing a monochrome bitmap with transparency

Raymond Chen
Raymond Chen

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 + 1);...

Code
Aug 2, 2005
Post comments count0
Post likes count0

Rendering menu glyphs is slightly trickier

Raymond Chen
Raymond Chen

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 prog...

Code
Aug 1, 2005
Post comments count0
Post likes count0

Rendering standard Windows elements

Raymond Chen
Raymond Chen

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 RootWindow::Pa...

Code
Jul 27, 2005
Post comments count0
Post likes count0

When the normal window destruction messages are thrown for a loop

Raymond Chen
Raymond Chen

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 intro...

Code
Jul 26, 2005
Post comments count0
Post likes count1

What is the difference between WM_DESTROY and WM_NCDESTROY?

Raymond Chen
Raymond Chen

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 when y...

Code