110,568
社区成员
发帖
与我相关
我的任务
分享
private void ShowContextMenu()
{
if ((this.contextMenu != null) || (this.contextMenuStrip != null))
{
NativeMethods.POINT pt = new NativeMethods.POINT();
UnsafeNativeMethods.GetCursorPos(pt);
UnsafeNativeMethods.SetForegroundWindow(new HandleRef(this.window, this.window.Handle));
if (this.contextMenu != null)
{
this.contextMenu.OnPopup(EventArgs.Empty);
SafeNativeMethods.TrackPopupMenuEx(new HandleRef(this.contextMenu, this.contextMenu.Handle), 0x48, pt.x, pt.y, new HandleRef(this.window, this.window.Handle), null);
UnsafeNativeMethods.PostMessage(new HandleRef(this.window, this.window.Handle), 0, IntPtr.Zero, IntPtr.Zero);
}
else if (this.contextMenuStrip != null)
{
this.contextMenuStrip.ShowInTaskbar(pt.x, pt.y);
}
}
}