IContextMenuCallback.AddItem失败 [英] IContextMenuCallback.AddItem failure

查看:89
本文介绍了IContextMenuCallback.AddItem失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力在.NET 4.0中实现IExtendContextMenu.我已经正确调用了接口,但是当我尝试添加菜单项时,我似乎无法通过System.Argument异常,并且该异常仅提供信息 CONTEXTMENUITEM值之一超出范围.在下面,我将显示我正在使用的导入信息.

I have been working on implementing IExtendContextMenu in .NET 4.0.  I have got the interfaces being called correctly, but when I try to add my menu item, I can't seem to get past the System.Argument exception and the exception only provides information that one of the CONTEXTMENUITEM values is out of range.  Below, I will show the import information that I am using.

首先,失败的函数调用:

First, the function call that is failing:

   CONTEXTMENUITEM l_item = new CONTEXTMENUITEM();
   l_item.fFlags = 0;
   l_item.fSpecialFlags = 0;
   l_item.lCommandID = MMC_VERB.PROPERTIES;
   l_item.lInsertionPointID = CCM.INSERTIONPOINTID_PRIMARY_TASK;
   l_item.strName = l_text;
   l_item.strStatusBarText = l_text;

   piCallback.AddItem(ref l_item);

其中piCallback是对传递到IExtendContextMenu.AddMenuItems中的IContextMenuCallback接口的引用.现在获取支持代码:

where piCallback is a reference to the IContextMenuCallback interface that is passed into IExtendContextMenu.AddMenuItems.  Now for the supporting code:

IContextMenuCallback:

IContextMenuCallback:

[ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("43136EB7-D36C-11CF-ADBC-00AA00A80033")]
 public interface IContextMenuCallback
 {
  void AddItem(ref CONTEXTMENUITEM pItem);
 }

上下文菜单项:

 [StructLayout(LayoutKind.Sequential)]
 public struct CONTEXTMENUITEM
 {
  [MarshalAs(UnmanagedType.LPWStr)]
  public String strName;
  [MarshalAs(UnmanagedType.LPWStr)]
  public String strStatusBarText;
  public long lCommandID;
  public long lInsertionPointID;
  public long fFlags;
  public long fSpecialFlags;
 }

MMC_Verb:

 public class MMC_VERB
 {
  public const uint NONE = 0x0000;
  public const uint OPEN = 0x8000;
  public const uint COPY = 0x8001;
  public const uint PASTE = 0x8002;
  public const uint DELETE = 0x8003;
  public const uint PROPERTIES = 0x8004;
  public const uint RENAME = 0x8005;
  public const uint REFRESH = 0x8006;
  public const uint PRINT = 0x8007;
  public const uint CUT = 0x8008;

  public const uint MAX = 0x8009;
  public const uint FIRST = OPEN;
  public const uint LAST = MAX - 1;
 }



有人对我可能会出错的地方有任何见解吗?


Anyone have any insights of where I may be going wrong?

如果您将任何有用的条目标记为有帮助的条目,并且该条目回答了您的问题,请在答案"链接中进行标记.

It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.





推荐答案

您好

Hi TSoftware,

我正在尝试让一些高级工程师参与此问题,这将需要一些时间.非常感谢您的耐心等候.

I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.


这篇关于IContextMenuCallback.AddItem失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆