/// <summary>プロパティを適用します。</summary>
        private void applyProperties()
        {
            if (this.AssociatedObject == null)
            {
                return;
            }

            var hWnd = new WindowInteropHelper(this.AssociatedObject).Handle;
            MetroWindowStyle styleFlag = 0;

            if (this.SystemMenuVisible)
            {
                styleFlag |= MetroWindowStyle.ShowSystemMenu;
            }
            if (this.CanMaxmize)
            {
                styleFlag |= MetroWindowStyle.CanMaxmize;
            }
            if (this.CanMinimize)
            {
                styleFlag |= MetroWindowStyle.CanMinimize;
            }

            WindowApis.ChangeWindowStyle(hWnd, styleFlag);
        }
Beispiel #2
0
        private void applyProperties()
        {
            if (this.AssociatedObject == null)
            {
                return;
            }

            if (this.IsVisible.HasValue)
            {
                var hwnd = new WindowInteropHelper(this.AssociatedObject).Handle;
                WindowApis.ChangeSystemMenuVisible(hwnd, this.IsVisible.Value);
            }
        }
        /// <summary>Windowメッセージフックプロシージャを表します。</summary>
        /// <param name="hWnd">ウィンドウハンドルを表すIntPtr。</param>
        /// <param name="msg">ウィンドウメッセージを表すint。</param>
        /// <param name="wParam">パラメータを表すIntPtr。</param>
        /// <param name="lParam">パラメータを表すIntPtr。</param>
        /// <param name="handled">Windowメッセージ処理結果を返すbool。</param>
        /// <returns>Windowメッセージの処理結果を表すIntPtr。</returns>
        private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WindowsApiConstants.WM_INITMENU)
            {
                // 閉じるメニュー
                WindowApis.ChangeSystemMenuItemEnabled(hWnd, SystemMenuItem.CloseItem, this.CanClose);
                // 最大化メニュー
                WindowApis.ChangeSystemMenuItemEnabled(hWnd, SystemMenuItem.MaxmizeItem, this.CanMaxmize);
                // 最小化メニュー
                WindowApis.ChangeSystemMenuItemEnabled(hWnd, SystemMenuItem.MinimizeItem, this.CanMinimize);
                // 移動メニュー
                WindowApis.ChangeSystemMenuItemEnabled(hWnd, SystemMenuItem.MoveItem, this.CanMove);
            }

            return(IntPtr.Zero);
        }