Print Page | Close Window

MDI tabbed docs and multiple docs

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=5467
Printed Date: 20 June 2025 at 5:53pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: MDI tabbed docs and multiple docs
Posted By: AndyL
Subject: MDI tabbed docs and multiple docs
Date Posted: 08 November 2006 at 12:48pm
I am writing an MDI application and using CJ CommandBars for the first time.
I would like to emulate the Visual Studio options of flicking from  a "Tabbed documents" to"Multiple documents" representation of the Child forms.
 
I think that the logic that I need is as follows.
If "Multiple Doc mode" selected then identify each tab and pick up each form, turn each form FontBordersStyle to "sizeable", remove the tabs from the CommandBar and redisplay the forms as standard MDI Child windows and cascade them in the parent form.
 
If "Tabbed doc selected" then identify all the open forms, turn off their FontBorderStyle, add correct number of tabs to the commandbar and load each form onto the tab.
 
Being a Newbie to CJ I am not sure where to start. I have the "tabbed" look working OK. Can anyone advise on what objects and methods I should be using to attempt this?
If anyone can provide code snippets that would be greatly appreciated.
 
Thank you. Andy.
 
 



Replies:
Posted By: AndyL
Date Posted: 14 November 2006 at 3:38pm

Well the task wasn't as simple as I expected. The main problem revolved around the clash between EnableGroups() and ShowTabWorkspace.

I attach a variation of the c# sample "MDISample" with a menu option called "Show Document Tab". Selecting this will toggle tabbed view and multiple document view.
N.B. I cannot use EnableGroups() in this code - it stops ShowTabWorkspace from working.
 
The key code is in a helper function

#region Helper functions

private void ChangeDocType(bool TabbedDocs)

{

m_TabbedDocs = TabbedDocs;

if (m_TabbedDocs == true)              //tabbed document display

{

  m_Workspace = CommandBars.ShowTabWorkspace(true);

  m_Workspace.Refresh();

  foreach (Form ctrl in this.MdiChildren)

  {

     ctrl.FormBorderStyle = FormBorderStyle.None;

     ctrl.WindowState = https://forum.codejock.com/uploads/20061114_153426_MDISample_2.zip -   System.Windows.Forms.FormWindowState.Maximized;

   }

   foreach (XtremeCommandBars.TabControlItem tci in CommandBars.TabWorkspace)

   {

       //MessageBox.Show(tci.Caption + " : " + tci.Handle.ToString() + " : ");

       //need to loop through the tabs and select them so that the form is redisplayed correctly

       //in the tab.

       m_Workspace.FindItem(tci.Handle).Selected = true;

    }

}

else                 //multi document display

{

m_Workspace = CommandBars.ShowTabWorkspace(false);

m_Workspace.Refresh();

foreach (Form ctrl in this.MdiChildren)

{

   //making the form invisible and then visible makes sure that it is redrawn correctly.

    //N.B. make sure that the form is not set to AutoSize

    ctrl.Visible = false;

    ctrl.AutoSize = false;

    ctrl.FormBorderStyle = FormBorderStyle.Sizable;

    ctrl.StartPosition = FormStartPosition.CenterParent;

    ctrl.WindowState = System.Windows.Forms.FormWindowState.Normal;

    ctrl.Visible = true;

}

this.LayoutMdi(MdiLayout.Cascade);

}

 

}

#endregion

Hope this helps someone

  uploads/20061114_153426_MDISample_2.zip - uploads/20061114_153426_MDISample_2.zip uploads/20061114_153625_MDISample_2.zip - uploads/20061114_153625_MDISample_2.zip


Posted By: AndyL
Date Posted: 14 November 2006 at 3:40pm
Excuse the links to the upload file - I wondered where they had gone - ignore them from the code snippet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net