Welcome to MSDN Blogs Sign in | Join | Help

How to host an IContextMenu, part 3 - Invocation location

One of the bugs you may have noticed in our first attempt at displaying the context menu to the user is that the Properties dialog doesn't show up at the point you clicked. The Properties dialog isn't psychic; it doesn't know where the original mouse click occurred. You have to tell it.

          CMINVOKECOMMANDINFOEX info = { 0 };
          info.cbSize = sizeof(info);
          info.fMask = CMIC_MASK_UNICODE | CMIC_MASK_PTINVOKE;
          info.hwnd = hwnd;
          info.lpVerb  = MAKEINTRESOURCEA(iCmd - SCRATCH_QCM_FIRST);
          info.lpVerbW = MAKEINTRESOURCEW(iCmd - SCRATCH_QCM_FIRST);
          info.nShow = SW_SHOWNORMAL;
          info.ptInvoke = pt;

You tell it by setting the CMIC_MASK_PTINVOKE flag in the fMask and specifying the invocation point in the ptInvoke member of the CMINVOKECOMMANDINFOEX structure.

Make this change and observe that now the Properties dialog appears at the point you clicked the mouse rather than in a random location on the screen.

Next time, we'll clean up another minor problem with our sample program.

Published Thursday, September 23, 2004 7:00 AM by oldnewthing
Filed under:

Comments

# re: How to host an IContextMenu, part 3 - Invocation location

Thursday, September 23, 2004 10:18 AM by Mike Dunn
hmm, the properties dlg always shows up at about (0,20) for me, not at the click location.

# re: How to host an IContextMenu, part 3 - Invocation location

Thursday, September 23, 2004 12:00 PM by Jack Mathews
That's funny, I never even noticed that the properties dialog showed up where the menu popped up in Explorer. Subtle, but nice.

# re: How to host an IContextMenu, part 3 - Invocation location

Sunday, September 26, 2004 6:33 PM by Raymond Chen
Mike: Odd, I took a brand new project, re-created the program and the properties dialog shows up at the click position.

# Shell Extensibility in Longhorn

Wednesday, October 13, 2004 9:29 AM by notgartner.com: Mitch Denny's Blog

# IContextMenu のホスト方法 - Shell

Wednesday, March 22, 2006 1:33 PM by 社本@ワック Blog
IContextMenu のホスト方法 - Shell
New Comments to this post are disabled
 
Page view tracker