The Old New Thing

Thread messages are eaten by modal loops

Thread messages (as generated by the function) do not go anywhere when passed to the function. This is obvious if you think about it, because there is no window handle associated with a thread message. has no idea what to do with a message with no associated window. It has no choice but to throw the message away. This has dire ...
Comments are closed.0 0
Code

What is the HINSTANCE passed to SetWindowsHookEx used for?

The function accepts a parameter. The documentation explains that it is a handle to the DLL containing the hook procedure. Why does the window manager need to have this handle? It needs the handle so it knows which DLL to load into each process when the hook fires. It injects the DLL you pass, then calls the function you pass. Clearly ...
Comments are closed.0 0
Code

The new scratch program

I think it's time to update the scratch program we've been using for the past year. I hear there's this new language called C++ that's going to become really popular any day now, so let's hop on the bandwagon! The basic idea of this program is the same as our old scratch program, but now it has that fresh lemony C++ scent. Instead of ...
Comments are closed.0 0
Code

The Itanium’s so-called stack

Last year I alluded to the fact that the Itanium processor has two stacks. The one that is traditionally thought of as "the stack" (and the one that the register refers to) is a manually managed block of memory from which a function can carve out space to use during its execution. For example, if you declare a local variable like then ...
Comments are closed.0 0
Code

What is the DC brush good for?

The DC brush is a stock brush associated with the device context. Like the system color brushes, the color of the DC brush changes dynamically, but whereas the system color brushes change color based on the system colors, the color of the DC brush changes at your command. The DC brush is handy when you need a solid color brush for a very...
Comments are closed.0 0
Code

What is the HINSTANCE passed to CreateWindow and RegisterClass used for?

One of the less-understood parameters to the function and the function is the (either passed as a parameter or as part of the structure). The window class name is not sufficient to identify the class uniquely. Each process has its own window class list, and each entry in the window class list consists of an instance handle and a ...
Comments are closed.0 4
Code

Tweaking our computation of the interval between two moments in time

We can take our computation of the interval between two moments in time and combine it with the trick we developed for using the powers of mathematics to simplify multi-level comparisons to reduce the amount of work we impose upon the time/date engine. Observe that we avoided a call to the method (which is presumably rather complicated ...
Comments are closed.0 0
Code

Computing the interval between two moments in time

Computing the interval between two moments in time is easy: It's just subtraction, but subtraction may not be what you want. If you are displaying time units on the order of months and years, then you run into the problem that a month is of variable length. some people just take the value relative to a base date of January 1 and extract ...
Comments are closed.0 0
Code

Using the powers of mathematics to simplify multi-level comparisons

What a boring title. Often you'll find yourself needing to perform a multi-level comparison. The most common example of this is performing a version check when there are major and minor version numbers involved. Bad version number checks are one of the most common sources of errors. If you're comparing version numbers, you can use the ...
Comments are closed.0 0
Code