Hide Maximize/Minimze buttons?
- Is there a way to hide the max/min buttons for the window? I know you can use ToolWindow, but I'm having some problems using that style (it gets lost in the ALT-TAB menu) so I need a different way. And I don't really want to rewrite the window chrome or redraw the borders if I don't have to.
答案
- Kofoed,
If you also don't want to resize the window, a ResizeMode="NoResize" will do it. It will remove them, but then, no resizing either.
Hope this helps.
noorbakhsh- 已标记为答案Kofoed 2009年7月6日 16:11
全部回复
- Kofoed,
If you also don't want to resize the window, a ResizeMode="NoResize" will do it. It will remove them, but then, no resizing either.
Hope this helps.
noorbakhsh- 已标记为答案Kofoed 2009年7月6日 16:11
Hi,
put this line of code after InitializeComponent
this.WindowStyle = WindowStyle.None;
hope solve ur problem
Harshad..... Always 4 U- Hi,
put this line of code after InitializeComponent()
this.WindowStyle = WindowStyle.None;
Hope Solve ur Problem............
Harshad..... Always 4 U - I don't understand why *all* resizing is disabled just because the min/max buttons are removed from the titlebar...
- Hi Kofoed,
You can remove the WS_MAXIMIZEBOX and WS_MINIMIZEBOX from the window style via P/Invoke.
[DllImport("user32.dll", SetLastError = true)] static extern int GetWindowLong(IntPtr hWnd, int nIndex); [DllImport("user32.dll")] static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); private const int GWL_STYLE = -16; private const int WS_MINIMIZEBOX = 0x20000; private const int WS_MAXIMIZEBOX = 0x10000; void Window5_Loaded(object sender, RoutedEventArgs e) { IntPtr hwnd = new WindowInteropHelper(this).Handle; long windowLong = GetWindowLong(hwnd, GWL_STYLE); windowLong = windowLong &~ WS_MAXIMIZEBOX; windowLong = windowLong &~ WS_MINIMIZEBOX; SetWindowLong(hwnd, GWL_STYLE, (int)windowLong); }
Best Regards,
Zhi-Xin
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.

