Showing results for September 2004 - Page 2 of 4 - The Old New Thing

Sep 22, 2004
0
0

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

Raymond Chen
Raymond Chen

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), GET...

Code
Sep 21, 2004
0
0

Swedes struggle with the meaning of sick leave

Raymond Chen
Raymond Chen

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 board a...

Non-Computer
Sep 21, 2004
0
0

Pitfalls in handling the WM_CONTEXTMENU message

Raymond Chen
Raymond Chen

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), GET_X_LPAR...

Code
Sep 20, 2004
0
0

How to host an IContextMenu, part 1 – Initial foray

Raymond Chen
Raymond Chen

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 just fo...

Code
Sep 17, 2004
0
0

Why does my mouse/touchpad sometimes go berzerk?

Raymond Chen
Raymond Chen

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. The byt...

Tips/Support
Sep 16, 2004
0
0

What happens when you specify RegexOptions.ECMAScript?

Raymond Chen
Raymond Chen

The 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 had trouble finding that page...

Code
Sep 16, 2004
0
0

A visual history of spam (and virus) email

Raymond Chen
Raymond Chen

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 at my...

Other
Sep 15, 2004
0
1

Interlocked operations don’t solve everything

Raymond Chen
Raymond Chen

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 atomi...

Code