문제

I've been attempting to have a wpf window that only has the minimize and close buttons on the window header, and not the maximize button.

My current best attempt is the following:

private const int GWL_STYLE = -16,
                      WS_MAXIMIZEBOX = 0x10000;

internal static void HideMaximizeButton(this Window window)
{
    IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(window).Handle;
    var currentStyle = GetWindowLong(hwnd, GWL_STYLE);
    SetWindowLong(hwnd, GWL_STYLE, (currentStyle & ~WS_MAXIMIZEBOX));
}

But the end result of this is just to gray out the maximize button, not to completely exclude it from the window header.

Any assistance would be greatly appreciated. Thanks

도움이 되었습니까?

해결책

You can't remove just the maximize button. However you can remove the whole ControlBox and add your own.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top