Domanda

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

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top