The Old New Thing

Building a dialog template at run-time

We've spent quite a bit of time over the past year learning about dialog templates and the dialog manager. Now we're going to put the pieces together to do something interesting: Building a dialog template on the fly. What we're going to write is an extremely lame version of the MessageBox function. Why bother writing a bad version of ...
Comments are closed.0 0
Code

Rescuing thread messages from modal loops via message filters

As we have seen recently, thread messages are eaten by modal loops because they have nowhere to go when dispatched. However, there is a way to see them before they vanish, provided the modal loop is cooperative. The WH_MSGFILTER message hook allows you to receive messages passed to the CallMsgFilter function. Fortunately, all the modal ...
Comments are closed.0 0
Code

Watching thread messages disappear

We saw last time that thread messages are eaten by modal loops. Today we'll illustrate, and then we'll try to fix it next time. Start with our scratch program and make the following changes: Run this program and notice that it beeps every two seconds, or at least it does most of the time. If you right-click on the caption bar or grab ...
Comments are closed.0 0
Code

If you pull a 1920's fire extinguisher out of the ocean, for pete's sake don't drink it!

Oceanographer Curtis Ebbesmeyer is a fascinating source of information. He appeared again on my local public radio station to discuss issues related to garbage floating in the ocean. For example, at the 5:05 mark, he reminds us that, if you pull a 1920's fire extinguisher out of the ocean, you shouldn't drink it. Other fascinating facts...

Thread messages are eaten by modal loops

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

Welcome to Millennium Tower, due for completion in May 2005

The friend who brought to my attention the guide to British pub etiquette reports that Portsmouth's Millennium Tower, centerpiece of the Millennium Project, is still not finished, due for completion (scroll to the end of the article) in May 2005. To disguise the embarrassment, they've renamed it to Spinnaker Tower, thereby—as the ...

What is the HINSTANCE passed to SetWindowsHookEx used for?

The SetWindowsHookEx function accepts a HINSTANCE 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 ...
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

Sweden's Worst Driver

Swedish Television announced a new reality-based television program called Sweden's Worst Driver (Sveriges värsta bilförare). I've done a bad job of translating some excerpts: TV4 has gathered seven of Sweden's worst drivers and subjects them to a series of tests and challenges. Those who complete each exercise the best get a prize...

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 sp 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

Feedback usabilla icon