Showing tag results for Code

Mar 7, 2006
Post comments count0
Post likes count0

The consequences of invalidating the null window

Raymond Chen
Raymond Chen

On occasion, you might notice that every window on the desktop flickers and repaints itself. One of the causes for this is a simple null handle bug. The function is one you're probably well-familiar with. It is used to indicate to the window manager that the pixels of a particular window are no longer current and should be repainted. (You can opt...

Code
Mar 3, 2006
Post comments count0
Post likes count0

Very late remarks on the original Chinese dictionary series

Raymond Chen
Raymond Chen

I have not forgotten about the Chinese/English dictionary series, but I simply haven't had the motivation to sit down and write up descriptions and discussion for the code that I wrote along the way, so instead of adding to the program, I'm going to answer some questions that were asked back when I started the series but which I didn't respond to a...

Code
Mar 2, 2006
Post comments count0
Post likes count0

Restating the obvious about the WM_COMMAND message

Raymond Chen
Raymond Chen

I'm satisfied with the MSDN documentation for the message, but for the sake of mind-numbing completeness, I'm going to state the obvious in the hope that you, dear readers, can use this technique to fill in the obvious in other parts of MSDN. The one-line summary of the message says, "The WM_COMMAND message is sent when the user selects a com...

Code
Mar 1, 2006
Post comments count0
Post likes count0

Keep your eye on the code page, practical exam

Raymond Chen
Raymond Chen

The instructions that came with my new monitor are printed in several languages. One of those languages is Polish, or at least it would be Polish if... well, you'll see. UWAGA: Szczegó³owe informacje dla u¿ytkownika znajduj¹ siê na do³¹czonej p³ycie CD. This is garbage. What they meant to write was UW...

Code
Feb 27, 2006
Post comments count0
Post likes count0

Changing a window class affects all windows which belong to that class

Raymond Chen
Raymond Chen

Sometimes you need to state the obvious, and that's fine. You can learn a lot from the obvious. For example, the first topic in my PDC talk consisted of simply stating the obvious. Occasionally, when you state the obvious, you have to follow up by stating the obvious. When I pointed out that the effect of lasts only until the next , one comment...

Code
Feb 23, 2006
Post comments count0
Post likes count1

Enumerating threads in a process

Raymond Chen
Raymond Chen

The tool helper library is sort of the black sheep of Win32. It grew out of the 16-bit TOOLHELP library, which provided services for system debugging tools to do things like take stack traces and enumerate all the memory in the system. The original incarnation of Win32 didn't incorporate it; it wasn't until Windows 95 that a 32-bit version o...

Code
Feb 22, 2006
Post comments count0
Post likes count1

The performance cost of reading a registry key

Raymond Chen
Raymond Chen

The registry is a convenient place to record persistent cross-process data in a uniform and multi-thread-safe manner. It roams with the user if you store it in , and individual keys can be secured (even on systems that use FAT, which doesn't otherwise support security). But that doesn't mean that it's free. The cost of opening a key, reading a v...

Code
Feb 21, 2006
Post comments count0
Post likes count0

In pursuit of the message queue

Raymond Chen
Raymond Chen

In 16-bit Windows, every thread (or "task" as it was called then) had a message queue, end of story. In the transition to 32-bit Windows, this model broke down because Win32 introduced the concepts of "worker threads" and "console applications", neither of which had much need for messaging. Creating a queue for every thread in the system would have...

Code
Feb 20, 2006
Post comments count0
Post likes count0

Why does my program run faster if I click and hold the caption bar?

Raymond Chen
Raymond Chen

Sometimes, people discover that a long-running task runs faster if you hold down the mouse. How can that be? This strange state of affairs typically results when a program is spending too much time updating its progress status and not enough time actually doing work. (In other words, the programmer messed up badly.) When you click and hold the m...

Code
Feb 16, 2006
Post comments count0
Post likes count0

Because programmers were trusted to do the right thing, part 2

Raymond Chen
Raymond Chen

Some time ago, I discussed briefly the philosophy of API design that prevailed in the early days. One of the places this manifested itself was in the area of power management. As originally designed, power management was a cooperative affair (as was nearly everything in Windows in the early days). When the user attempted to put the computer into a...

Code