Exemplo n.º 1
0
        /// <summary>WindowのStyleを変更します。</summary>
        /// <param name="hWnd">ウィンドウハンドルを表すIntPtr。</param>
        /// <param name="styleFlag">Windowに設定するStyleを表すMetroWindowStyle列挙型フラグ。</param>
        public static void ChangeWindowStyle(IntPtr hWnd, MetroWindowStyle styleFlag)
        {
            var style = WindowApis.GetWindowLong(hWnd, ApiConstants.GWL_STYLE);

            if ((styleFlag & MetroWindowStyle.CanMaxmize) == MetroWindowStyle.CanMaxmize)
            {
                style |= ApiConstants.WS_MAXIMIZEBOX;
            }
            else
            {
                style &= ~ApiConstants.WS_MAXIMIZEBOX;
            }

            if ((styleFlag & MetroWindowStyle.CanMinimize) == MetroWindowStyle.CanMinimize)
            {
                style |= ApiConstants.WS_MINIMIZEBOX;
            }
            else
            {
                style &= ~ApiConstants.WS_MINIMIZEBOX;
            }

            if ((styleFlag & MetroWindowStyle.ShowSystemMenu) == MetroWindowStyle.ShowSystemMenu)
            {
                style |= ApiConstants.WS_SYSMENU;
            }
            else
            {
                style &= ~ApiConstants.WS_SYSMENU;
            }

            WindowApis.SetWindowLong(hWnd, ApiConstants.GWL_STYLE, style);
        }
Exemplo n.º 2
0
        /// <summary>システムメニュー項目の有効/無効を設定します。</summary>
        /// <param name="hWnd">対象のウィンドウハンドルを表すIntPtr。</param>
        /// <param name="menuItem">システムメニュー項目を表すSystemMenuItem列挙型の内の1つ</param>
        /// <param name="isEnabled">設定する有効状態を表すbool。</param>
        public static void ChangeSystemMenuItemEnabled(IntPtr hWnd, SystemMenuItem menuItem, bool isEnabled)
        {
            var hMenu = WindowApis.GetSystemMenu(hWnd, false);

            if (hMenu == IntPtr.Zero)
            {
                return;
            }

            var enabled = isEnabled ? ApiConstants.MF_BYCOMMAND | ApiConstants.MF_ENABLED :
                          ApiConstants.MF_BYCOMMAND | ApiConstants.MF_GRAYED;

            WindowApis.EnableMenuItem(hMenu, (uint)menuItem, enabled);
        }
Exemplo n.º 3
0
        public static void ChangeSystemMenuVisible(IntPtr hwnd, bool visible)
        {
            var style = WindowApis.GetWindowLong(hwnd, ApiConstants.GWL_STYLE);

            if (visible)
            {
                style |= ApiConstants.WS_SYSMENU;
            }
            else
            {
                style &= ~ApiConstants.WS_SYSMENU;
            }

            WindowApis.SetWindowLong(hwnd, ApiConstants.GWL_STYLE, style);
        }