Question

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

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top