Posted 15 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)
{
base.OnSourceInitialized(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:
http://msdn.microsoft.com/en-us/library/aa972163.aspx
[Modified at 03/04/2010 02:39 PM]
Code Snippet:
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(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:
http://msdn.microsoft.com/en-us/library/aa972163.aspx
[Modified at 03/04/2010 02:39 PM]