Posted 14 years ago
by henryw_au
Version: 9.1.0500
Platform: .NET 3.5
Environment: Windows XP (32-bit)
![Avatar](https://secure.gravatar.com/avatar/36faa999181592df3e7727e1ac88e28e.jpg?s=64&d=identicon&r=g)
Hello,
I'm trying to hide the window's max/min/close buttons. Here's the code I am using in a ribbon window:
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
private const int WS_MAXIMIZEBOX = 0x10000;
private const int WS_MINIMIZEBOX = 0x20000;
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
...
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var hwnd = new WindowInteropHelper((Window)this).Handle;
int cur = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, cur ^ (WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
}
It just doesnot work. The Max/Min/Close still there. Because the above code does work in a WPF window(I've tested), so I suspect it's a bug in RibbonWindow. Or there's different usage for ribbon window. Please help
Thanks
I'm trying to hide the window's max/min/close buttons. Here's the code I am using in a ribbon window:
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
private const int WS_MAXIMIZEBOX = 0x10000;
private const int WS_MINIMIZEBOX = 0x20000;
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
...
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var hwnd = new WindowInteropHelper((Window)this).Handle;
int cur = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, cur ^ (WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
}
It just doesnot work. The Max/Min/Close still there. Because the above code does work in a WPF window(I've tested), so I suspect it's a bug in RibbonWindow. Or there's different usage for ribbon window. Please help
Thanks