Showing tag results for Code

Oct 25, 2004
Post comments count0
Post likes count1

Accessing the current module’s HINSTANCE from a static library

Raymond Chen
Raymond Chen

If you're writing a static library, you may have need to access the HINSTANCE of the module that you have been linked into. You could require that the module that links you in pass the HINSTANCE to a special initialization function, but odds are that people will forget to do this. If you are using a Microsoft linker, you can take advantage of a ...

Code
Oct 21, 2004
Post comments count0
Post likes count0

Let WMI do the heavy lifting of determining system information

Raymond Chen
Raymond Chen

Windows Management Instrumentation is a scriptable interface to configuration information. This saves you the trouble of having to figure it out yourself. For example, here's a little program that enumerates all the CPUs in your system and prints some basic information about them. var locator = WScript.CreateObject("WbemScripting.SWbemLocator...

Code
Oct 18, 2004
Post comments count0
Post likes count0

Implementing higher-order clicks

Raymond Chen
Raymond Chen

Another question people ask is "How do I do triple-click or higher?" Once you see the algorithm for double-clicks, extending it to higher order clicks should be fairly natural. The first thing you probably should do is to remove the CS_DBLCLKS style from your class because you want to do multiple-click management manually. Next, you can simply...

Code
Oct 15, 2004
Post comments count0
Post likes count0

Logical consequences of the way Windows converts single-clicks into double-clicks

Raymond Chen
Raymond Chen

First, I'm going to refer you to the MSDN documentation on mouse clicks, since that's the starting point. I'm going to assume that you know the mechanics of how single-clicks are converted to double-clicks. Okay, now that you've read it, let's talk about some logical consequences of that article and what it means for the way you design your use...

Code
Oct 7, 2004
Post comments count0
Post likes count0

How to host an IContextMenu, part 11 – Composite extensions – composition

Raymond Chen
Raymond Chen

Okay, now that we have two context menu handlers we want to compose (namely, the "real" one from the shell namespace and a "fake" one that contains bonus commands we want to add), we can use merge them together by means of a composite context menu handler. The kernel of the composite context menu is to multiplex multiple context menus onto a sin...

Code
Oct 4, 2004
Post comments count0
Post likes count0

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

Raymond Chen
Raymond Chen

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

Code
Oct 1, 2004
Post comments count0
Post likes count0

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

Raymond Chen
Raymond Chen

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

Code
Sep 30, 2004
Post comments count0
Post likes count1

How to host an IContextMenu, part 7 – Invoking the default verb

Raymond Chen
Raymond Chen

When we last left our hero, we were wondering how to invoke the default verb programmatically. Now that we've learned a lot about how IContextMenu is used in the interactive case, we can use that information to guide us in its use in the noninteractive case. The key here is using the HMENU to identify the default menu item and just invoke it d...

Code
Sep 28, 2004
Post comments count0
Post likes count0

How to host an IContextMenu, part 6 – Displaying menu help

Raymond Chen
Raymond Chen

One of the subtleties of context menus is showing help in the status bar. Now, the program we've been developing doesn't have a status bar, so we'll fake it by putting the help text in the title bar. The key method for this task is IContextMenu::GetCommandString, which allows communication with a context menu handler about the verbs in the men...

Code