BUG: Ribbon Window incompatible with SetWindowPlacement()

Ribbon for WPF Forum

Posted 14 years ago by SledgeHammer01
Version: 9.2.0514
Platform: .NET 4.0
Environment: Windows XP (32-bit)
In order to save / restore the main application window, we use (via interop) the GetWindowPlacement() / SetWindowPlacement() APIs. We use this in OnSourceInitialized() as demonstrated by a Microsoft code sample. When the saved state is SW_SHOWMAXIMIZED, the window is restored to the maximized state correctly, BUT, the frame retains its rounded corners window region. Maximizing via double clicking the caption bar removes the rounded corner window region and squares off the corners as expected. I was able to work around this by adding a call to WindowState = WindowState.Maximized; in the case of SW_SHOWMAXIMZIED, but thought I would report the bug nonetheless.

Code Snippet:

protected override void OnSourceInitialized(EventArgs e)

// restore the window position

WINDOWPLACEMENT wp = (WINDOWPLACEMENT)Properties.Settings.Default.WindowPlacement;
wp.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
wp.flags = 0;
wp.showCmd = ( wp.showCmd == SW_SHOWMINIMIZED ? SW_SHOWNORMAL : wp.showCmd);
IntPtr hwnd = new WindowInteropHelper(this).Handle;
SetWindowPlacement(hwnd, ref wp);

EDIT: The sample I am referring to is here. It contains all the interop definitions:


[Modified at 03/04/2010 02:39 PM]

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Thanks for the note, we'll mark it down.

Actipro Software Support

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.