Showing tag results for Code

Feb 22, 2007
Post comments count0
Post likes count1

With what operations is LockWindowUpdate not meant to be used?

Raymond Chen

Okay, now that we know what operations is meant to be used with, we can look at various ways people misuse the function for things unrelated to dragging. People see the "the window you lock won't be able to redraw itself" behavior of and use it as a sort of lazy version of the message. Though sending the message really isn't that much harder ...

Code
Feb 21, 2007
Post comments count0
Post likes count1

With what operations is LockWindowUpdate meant to be used?

Raymond Chen

As I noted earlier, the intended purpose of can be captured in one word: dragging. The simplest case of is used by the window manager when you move or resize a window and "Show window contents while dragging" is disabled. When you start the move/size operation, the window manager locks the entire desktop so it can draw the dotted-rectangle feed...

Code
Feb 20, 2007
Post comments count0
Post likes count1

How is LockWindowUpdate meant to be used?

Raymond Chen

Now that we know how works, we can look at what it is for. Actually, the intended purpose of can be captured in one word: dragging. But we'll get to that a little later. The purpose of is to allow a program to temporarily take over the responsibility of drawing a window. Of course, in order to do this, you have to prevent the window procedure...

Code
Feb 19, 2007
Post comments count0
Post likes count1

What does LockWindowUpdate do?

Raymond Chen

Poor misunderstood . This is the first in a series on , what it does, what it's for and (perhaps most important) what it's not for. What does is pretty simple. When a window is locked, all attempt to draw into it or its children fail. Instead of drawing, the window manager remembers which parts of the window the application tried to draw into...

Code
Feb 16, 2007
Post comments count0
Post likes count1

Why don't I use any class libraries in my sample code?

Raymond Chen

As a general rule, I avoid using any class libraries in my sample code. This isn't because I'm opposed to class libraries, but rather because I don't want to narrow my audience to "people who use MFC" (to choose one popular class library). If I were to start using MFC for all of my samples, I'd probably lose all the people who don't use MFC. "Oh, ...

Code
Feb 8, 2007
Post comments count0
Post likes count1

Why does my property sheet blink and the immediately disappear?

Raymond Chen

Occasionally, a customer will ask, "I'm trying to display a property sheet, but when I call the function, the property sheet blinks onto the screen and then immediately disappears. What is wrong?" Recall that displaying a property sheet entails filling out a structure, which in turn contains a pointer to either an array of s, or more often, an a...

Code
Feb 7, 2007
Post comments count0
Post likes count1

Why can't I create my dialog box? Rookie mistake #2

Raymond Chen

Another class of rookie mistake is less obvious from looking at the code. The problem with this code is that we forgot to call to register the listview class. More generally, the problem is that one of the controls on the dialog uses a window class that was not registered. (For example, maybe there's a rich edit control on the dialog, but nobo...

Code
Feb 6, 2007
Post comments count0
Post likes count1

Why can't I create my dialog box? Rookie mistake #1

Raymond Chen

Each dialog box resource is specified either by an integer ordinal or by a string name. But a simple typo will turn one into the other. Do you see the two "classic rookie mistakes"? It may be easier to spot if you take the resource file and send it through the preprocessor first: The first call to passes as the resource name. But notice ...

Code
Jan 29, 2007
Post comments count0
Post likes count1

If vertical strips are better, why do toolbars use horizontal strips?

Raymond Chen

If vertical strips are better, why do toolbars use horizontal strips? An early version of the toolbar control first made its appearance in Windows 3.0, and in those days, screen resolutions were low and toolbar buttons were small. Horizontal or vertical didn't really matter. Ten bitmaps, each 16 × 16, at 4-bit color, comes out to one ...

Code
Jan 23, 2007
Post comments count0
Post likes count1

Non-psychic debugging: If you can't find something, make sure you're looking in the right place

Raymond Chen

This isn't psychic debugging, but it's the sort of dumb mistake everybody makes and which you can't see when re-reading your code because your brain shows you what you want to see, not what's really there. I'm trying to respond to the notification, but it's not working. What am I doing wrong? You can stare at this code for ages and completel...

Code