SetWindowLong() doesnot work on RibbonWindow

Ribbon for WPF Forum

Posted 9 years ago by henryw_au
Version: 9.1.0500
Platform: Windows Forms Controls
Environment: Windows XP (32-bit)
Avatar
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

Comments (1)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi,

Since RibbonWindow uses a custom chrome, the buttons are defined in our Style for RibbonWindow, not via API. So doing the settings you indicated will not affect RibbonWindow.

RibbonWindow does have IsMaximizeButtonVisible and IsMinimizeButtonVisible properties that you can use, however those may have been added after the build you indicated you have. There isn't a built-in option to hide the close button though. That would have to be done via a custom template.


Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.