SetWindowLong() doesnot work on RibbonWindow

Ribbon for WPF Forum

Posted 14 years ago by henryw_au
Version: 9.1.0500
Platform: .NET 3.5
Environment: Windows XP (32-bit)

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);
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);

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


Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA

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 (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.