Return to Snippet

Revision: 25521
at April 1, 2010 11:52 by mkurdziel


Initial Code
internal static class WindowExtensions
{
    [DllImport("user32.dll")]
    internal extern static int SetWindowLong(IntPtr hwnd, int index, int value);

    [DllImport("user32.dll")]
    internal extern static int GetWindowLong(IntPtr hwnd, int index);

    internal static void HideMinimizeAndMaximizeButtons(this Window window)
    {
        const int GWL_STYLE = -16;

        IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(window).Handle;
        long value = GetWindowLong(hwnd, GWL_STYLE);

        SetWindowLong(hwnd, GWL_STYLE, (int)(value & -131073 & -65537));

    }
}

this.SourceInitialized += (x, y) =>
{
    this.HideMinimizeAndMaximizeButtons();
};

Initial URL
http://stackoverflow.com/questions/339620/how-do-i-remove-minimize-and-maximize-from-a-resizable-window-in-wpf

Initial Description


Initial Title
Hide Minimize and Maximize Buttons

Initial Tags


Initial Language
C#