/// <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); }
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); }