Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- };
- <Window x:Class="DataBinding.MyWindow" ...Title="MyWindow" Height="300" Width="300"
- WindowStyle="ToolWindow" ResizeMode="CanResizeWithGrip">
- <Window x:Class="Example"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="Example"
- StateChanged="Window_StateChanged">
- // Disable maximizing this window
- private void Window_StateChanged(object sender, EventArgs e)
- {
- if (this.WindowState == WindowState.Maximized)
- this.WindowState = WindowState.Normal;
- }
Add Comment
Please, Sign In to add comment