Exemplo n.º 1
0
        public static void ShowSystemMenu(IntPtr hwnd)
        {
            if (hwnd == IntPtr.Zero)
            {
                return;
            }

            Point defPnt = new Point();

            WinAPI.GetCursorPos(ref defPnt);

            IntPtr hmenu = WinAPI.GetSystemMenu(hwnd, false);
            IntPtr cmd   = WinAPI.TrackPopupMenuEx(hmenu, Constants.TPM_LEFTBUTTON | Constants.TPM_RETURNCMD, (uint)defPnt.X, (uint)defPnt.Y, hwnd, IntPtr.Zero);


            if (cmd != IntPtr.Zero)
            {
                WinAPI.PostMessage(hwnd, Constants.WM_SYSCOMMAND, cmd, IntPtr.Zero);
            }
        }