Articles in this section
Category / Section

How to save or load the state information in a form which contains both the TabbedMDIManager and WinForms Docking Manager?

1 min read

Save or load the MDI child state

In General, the MDIChild states are maintained by the TabbedMDIManager. The DockingManager persists information about whether a particular window is an MDIChild or not. Hence the DockingManager’s PersistState property will not persist the TabbedMDI state and this has to be done through the TabbedMDIManager’s SaveTabGroupStates or LoadTabGroupStates methods.

SaveTabGroupStates:

It is always better to call the TabbedMDIManager’s SaveTabGroupStates method, from Form.WndProc method. This has to be done in response to the WM_CLOSE message. This will force the TabbedMDIManager to persist the MDIChild state before the DockingManager has a chance to clear it up.

LoadTabGroupStates:

The TabbedMDIManager’s LoadTabGroupStates method should be invoked from the DockingManager’s NewDockStateEndLoad event. This event gets fired after the docking windows state has been loaded.

Now the persisted TabbedMDI state should be applied to MDIChild forms. Please refe rthe below code snippet which illustrates this:

C#

protected override void WndProc(ref Message m)
{
   if(m.Msg == 0x0010/*WM_CLOSE*/)
   {
      // Save the TabbedMDIManager state before the Form gets a chance to generate the Closing event
      this.tabbedMDIManager.SaveTabGroupStates();
   }
   base.WndProc(ref m);
}
private void dockingManager1_NewDockStateEndLoad(object sender, System.EventArgs e)
{
      this.tabbedMDIManager.LoadTabGroupStates();
}

 

VB

Protected Overrides Sub WndProc(ByRef m As Message)
    if(m.Msg == 0x0010/*WM_CLOSE*/)
       If m.Msg = &H0010 Then
           'Save the TabbedMDIManager state before the Form gets a chance to generate the Closing event
           Me.tabbedMDIManager.SaveTabGroupStates()
       End If
       MyBase.WndProc(m)
End Sub
Private Sub dockingManager1_NewDockStateEndLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles dockingManager1.NewDockStateEndLoad
           Me.tabbedMDIManager.LoadTabGroupStates()
End Sub

Sample: http://help.syncfusion.com/support/samples/KB/Tools.Windows/TDDockTab/DockTab.zip

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied