Minimize main window with a maximized DocumentWindow

Docking/MDI for WPF Forum

Posted 10 years ago by Valéry Sablonnière - Staubli
Version: 14.1.0602
Platform: .NET 4.5
Environment: Windows 7 (32-bit)
Avatar

Hi,

When you run the Docking/MDI-Documents/Demos/Features (external window) sample and

  • maximize the main window
  • set a DocumentWindow in floating mode
  • maximize this window in the second monitor
  • minimize the main window
  • maximize the main window

Then the applications crashes with:

System.InvalidOperationException was unhandled
Message: An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll
Additional information: Impossible d'afficher la fenêtre lorsque ShowActivated a la valeur false et que WindowState a la valeur Maximized.

Comments (15)

Answer - Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Thanks for reporting this.  We have fixed it for the next version.

You can temporarily work around it by putting this in your App.Resources:

<Style TargetType="docking:RaftingWindow">
    <Setter Property="ShowActivated" Value="True" />
</Style>


Actipro Software Support

Posted 9 years ago by Michael Jelley
Avatar

Hello,

Is there any update on the build containing this fix? Is it in 0611? We've hit an almost identical issue, but with a maximized ToolWindow.

Thanks,
Michael

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

Hi Michael,

The fix for this particular issue was in 2014.2 build 610.


Actipro Software Support

Posted 8 years ago by Thomas Dupuis
Avatar

Hello, I'm reopening this issue since we are facing the exact same problem on 2016.1.630.0, on toolwindows.

"System.InvalidOperationException: Cannot show Window when ShowActivated is false and WindowState is set to Maximized."

I've read the 2 patchnotes released since the 630.0 version and haven't found any mention of this bug.

We are currently deploying the application towards clients and this issue is quite important.

Do you have any idea what is causing the issue and what we could do to solve the problem? 

To repro, we do:

Maximize the main window
Set a ToolWindow in floating mode
Maximize this window in the second monitor
Minimize the main window
Maximize the main window

We are using Actipro WPF following the MVVM model included in the documentation/example.

Style-wise, we have defined:

<Style x:Key="DockingWindowStyle" TargetType="docking:DockingWindow">
<Setter Property="Description" Value="{Binding Path=Description, Mode=TwoWay}" />
<Setter Property="ImageSource" Value="{Binding Path=ImageSource, Mode=TwoWay}" />
<Setter Property="IsActive" Value="{Binding Path=IsActive, Mode=TwoWay}" />
<Setter Property="IsOpen" Value="{Binding Path=IsOpen, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
<Setter Property="SerializationId" Value="{Binding Path=SerializationId, Mode=TwoWay}" />
<Setter Property="Title" Value="{Binding Path=Title, Mode=TwoWay}" />
<Setter Property="WindowGroupName" Value="{Binding Path=WindowGroupName, Mode=TwoWay}" />
</Style>
<Style x:Key="DockSiteStyle" TargetType="docking:DockSite">
<Setter Property="ToolWindowsHaveTabImages" Value="True"/>
<Setter Property="ToolWindowsTabStripPlacement" Value="Bottom"/>
<Setter Property="CanToolWindowsBecomeDocuments" Value="False"/>
<Setter Property="CanDocumentWindowsFloat" Value="True"/>
</Style>

<Style x:Key="ToolWindowStyle" TargetType="docking:ToolWindow" BasedOn="{StaticResource DockingWindowStyle}">
<Setter Property="DefaultDockSide" Value="{Binding Path=DefaultDockSide, Mode=TwoWay, Converter={StaticResource ToolItemDockSideConverter}}" />
<Setter Property="State" Value="{Binding Path=State, Mode=TwoWay, Converter={StaticResource ToolItemStateConverter}}" />
</Style>

 

Thanks,

Thomas

[Modified 8 years ago]

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

Hi Thomas,

That sounds familiar and like something we might have already fixed since the first 2016.1 release.  It could be that we didn't put a Release History note specifically related to it.  I would urge you to try the latest build and report back if you still see it happening there.


Actipro Software Support

Posted 8 years ago by Thomas Dupuis
Avatar

Thank you very much for your (super fast) answer.

We will try updating to the newest version then (with hopefully no regression)

Thanks again!

Posted 8 years ago by Mario Sirois
Avatar

Yes it is fixing the problem, but when we restore the application, the floating window that was full screen is not fullscreen anymore. We sometime don't even see it at all or sometime the floating window is floating with a non maximised size.

It is possible to verify if this is an issue on your side ?

Thanks

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

Hi Mario,

Since this request requires a scenario to be reproduced, can you please put together a new simple sample showing the issue and email that to our support address?  In your email, reference this thread and give the instructions to reproduce the problem.  Also be sure to rename the .zip file extension to something like .txt so it doesn't get spam blocked.  Once we have that, we can debug it to see what's going on and make any changes that are necessary.


Actipro Software Support

Posted 8 years ago by Mario Sirois
Avatar

Hi

I can reproduce my issue in your Actipro Software WPF Controls, in Docking/MDI - Demos

Undock the solution explorer and put it full screen on the second monitor.

Minimize the application in the task bar.

Restore back the application by clicking in the taskbar.

Notice the solution explorer won't be fullscreen anymore

Thanks.

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

Hi Mario,

What we had described earlier in the thread was that the exception was fixed.  But the scenario you describe is tricky and is caused by native WPF.  This scenario was also present in Docking/MDI prior to v2016.1.

What happens is that when the root Window minimizes, since it "owns" the other floating Window that hosts tool windows via Window.OwnedWindows, the Windows system hides the floating Window.  When you restore the root Window again, the floating Window is still flagged as Maximized, but then Windows sends it a WM_SIZE message that causes it to restore back to Normal state.  This happens after anything that we can really watch for, so I'm not sure how we could implement a workaround for this.

You can reproduce the same thing if you make a new WPF app and in a Window.Loaded event handler, use code like this:

private void OnWindowLoaded(object sender, RoutedEventArgs e) {
	var w = new Window();
	w.Owner = this;
	w.Title = "Test";
	w.Show();
}

Then maximize that Test Window on another monitor and minimize/restore the main Window to see the same effect.  We're open to any suggestions if you have workaround ideas.


Actipro Software Support

Posted 7 years ago by Thomas Dupuis
Avatar

Hey Actipro, 

I'm reopening this thread since we found a new way to reproduce this issue (the crash, not the not-maximized issue)

"System.InvalidOperationException: Cannot show Window when ShowActivated is false and WindowState is set to Maximized."

I can reproduce in every version, including the latest, in your sample.

- Open Actipro Software WPF Controls 0635

- Click on Docking/MDI

- Go in +33 more (in Samples)

- Click on "Layout Serialization"

- Drag the Solution Explorer outside the application, so it become a floating window

- Maximise it.

- Layout>Save Layout

- Layout>Load Layout

- Minimize the application (by clicking on the icon in the task bar for example)

- Click again on the icon in the task bar to restore it.

- Notice how the application crashes.

Basically, it happens when the Serializer is loading a layout with a maximized toolwindow. It doesn't crash in the first loading, but when we try to restore the application after being minimized.

It impacts our application currently in production.

If you have any quick fix before a new release, we would be very interested (our application in production is currently using the 633 version, and our latest in developement, almost in prod is using 634) We would like to hotfix it, while waiting for a more stable Actipro version.

Thanks a lot.

ps: The problem occurs on Win7 and Win10

[Modified 7 years ago]

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

Hi Thomas,

Thanks for reporting this scenario.  We added a line of code that seems to work around the problem by resetting ShowActivated to true after the dock host floating Window is shown.  If you'd like to try a preview build of the upcoming 2016.1 maintenance release with this change, please write our support address.  Mention this thread and we'll send you the link.


Actipro Software Support

Posted 7 years ago by Thomas Dupuis
Avatar

Thank you for your fast answer.

Is there a quick fix we could add on our side, so we can avoid the update to a new version of Actipro? (it takes a long time to test our application when we update an important third party like this)

Could you provide me the code which reset the ShowActivated to true if it can be called from outside your dll?

Thanks a lot.

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

The code we added executes internally after the Window.Show method is called and there's no direct spot for you to mimic the same.

The only possible external workaround I can think of is to handle the DockSite.FloatingWindowOpening event.  In that the e.DockHost is passed.  Look at the parent of that and it should be a Window.  Handle the Window.Activated event and set ShowActivated = true.  Then detach the handler so it doesn't happen again.  See if that works around it, but if not, you'd probably need to get our latest preview build 636 for a proper fix.


Actipro Software Support

Posted 7 years ago by Thomas Dupuis
Avatar

This workaround seems to work well. We are going to use it for now.

Thank you very much for you fast and precise replies.

The latest build of this product (v24.1.1) 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.