Пример #1
0
        public void ShowPopupMenu(Point windowRelativePosition, Control owner, PopupMenuFlags flags, Rect excludeRect)
        {
            Point screenPosition = windowRelativePosition;
            bool  success        = NativeMethods.ClientToScreen(owner.Handle, ref screenPosition);

            if (!success)
            {
                throw new System.ComponentModel.Win32Exception();
            }

            TPMPARAMS paramStruct = new TPMPARAMS();

            paramStruct.cbStruct  = Convert.ToUInt32(Marshal.SizeOf <TPMPARAMS>());
            paramStruct.rcExclude = excludeRect;

            using (StructureBuffer <TPMPARAMS> ptr = new StructureBuffer <TPMPARAMS>())
            {
                ptr.Value = paramStruct;
                NativeMethods.TrackPopupMenuEx(Handle, (uint)flags, screenPosition.x, screenPosition.y, owner.Handle, ptr.Handle);
            }
        }
Пример #2
0
 public static extern uint TrackPopupMenuEx(IntPtr hmenu, uint fuFlags, int x, int y, IntPtr hwnd, [In] ref TPMPARAMS lptpm);