The Old New Thing

The macros for declaring and implementing COM interfaces

There are two ways of declaring COM interfaces, the hard way and the easy way. The easy way is to use an IDL file and let the MIDL compiler generate your COM interface for you. If you let MIDL do the work, then you also get __uuidof support at no extra charge, which is a very nice bonus. The hard way is to do it all by hand. If you ...

Those partisan non-partisan groups

Just because they say they're non-partisan doesn't mean that they're non-partisan. Friday night, I got a phone call from "Victor" at "Washington Counts" who came right out and asked me whom I was going to vote for. I asked him to repeat the name of the organization he represents, and he said, "Washington Counts, a non-partisan ...

How to host an IContextMenu, part 9 – Adding custom commands

The indexMenu, idCmdFirst and idCmdLast parameters to the IContextMenu::QueryContextMenu method allow you, the host, to control where in the context menu the IContextMenu will insert its commands. To illustrate this, let's put two bonus commands on our context menu, with the boring names "Top" and "Bottom". We need to reserve some space in...

How to host an IContextMenu, part 8 – Optimizing for the default command

There is a small improvement that can be made to to the program we wrote last time. It involves taking advantage of the last parameter to the IContextMenu::QueryContextMenu method: CMF_DEFAULTONLY This flag is set when the user is activating the default action, typically by double-clicking. This flag provides a hint for the shortcut menu...