The Old New Thing

How to host an IContextMenu, part 2 – Displaying the context menu

Instead of invoking a fixed verb, we'll ask the user to choose from the context menu and invoke the result. Make these changes to the OnContextMenu function: #define SCRATCH_QCM_FIRST 1 #define SCRATCH_QCM_LAST 0x7FFF #undef HANDLE_WM_CONTEXTMENU #define HANDLE_WM_CONTEXTMENU(hwnd, wParam, lParam, fn) \ ((fn)((hwnd), (HWND)(wParam...
Comments are closed.0 0
Code

Swedes struggle with the meaning of sick leave

As part of the continuing campaign to shed their hard-working stereotype, perhaps taking a cue from their more well-adjusted Norwegian neighbors, Swedes have been taking dubious sick leave in record numbers. [A] study showed 40 percent believe it is enough to feel tired to stay home and draw benefits. A survey of 1,002 Swedes by the ...

Pitfalls in handling the WM_CONTEXTMENU message

Before we continue with our IContextMenu discussion, I need to take a little side trip and discuss the subtleties of the WM_CONTEXTMENU message. First, a correction to the existing <windowsx.h> header file: #undef HANDLE_WM_CONTEXTMENU #define HANDLE_WM_CONTEXTMENU(hwnd, wParam, lParam, fn) \ ((fn)((hwnd), (HWND)(wParam), ...
Comments are closed.0 0
Code

How to host an IContextMenu, part 1 – Initial foray

Most documentation describes how to plug into the shell context menu structure and be a context menu provider. If you read the documentation from the other side, then you also see how to host the context menu. (This is the first of an eleven-part series with three digressions. Yes, eleven parts—sorry for all you folks who are in it ...
Comments are closed.0 0
Code

Why does my mouse/touchpad sometimes go berzerk?

Each time you move a PS/2-style mouse, the mouse send three bytes to the computer. For the sake of illustration, let's say the three bytes are x, y, and buttons. The operating system sees this byte stream and groups them into threes: x y b x y b x y b x y b Now suppose the cable is a bit jiggled loose and one of the "y"s gets lost. ...

A visual history of spam (and virus) email

I have kept every single piece of spam and virus email since mid-1997. Occasionally, it comes in handy, for example, to add naïve Bayesian spam filter to my custom-written email filter. And occasionally I use it to build a chart of spam and virus email. The following chart plots every single piece of spam and virus email that arrived ...

What happens when you specify RegexOptions.ECMAScript?

The RegexOptions.ECMAScript flag changes the behavior of .NET regular expressions. One of the changes I had discussed earlier was with respect to matching digits. For those who want to know more, a summary of the differences is documented in MSDN under the devious title "ECMAScript vs. Canonical Matching Behavior". Apparently some people ...
Comments are closed.0 0
Code

Interlocked operations don’t solve everything

Interlocked operations are a high-performance way of updating DWORD-sized or pointer-sized values in an atomic manner. Note, however, that this doesn't mean that you can avoid the critical section. For example, suppose you have a critical section that protects a variable, and in some other part of the code, you want to update the variable ...
Comments are closed.0 0
Code