Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Docking Pane
  New Posts New Posts RSS Feed - No titles on docking panes at all in C#
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

No titles on docking panes at all in C#

 Post Reply Post Reply
Author
Message
bjust View Drop Down
Groupie
Groupie


Joined: 22 December 2010
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote bjust Quote  Post ReplyReply Direct Link To This Post Topic: No titles on docking panes at all in C#
    Posted: 29 December 2010 at 6:39pm
I am in the process of porting our GUI from VB6 to C#.  I have several problems with the docking panes in C#.  Here is the setup:

- The main window is an MDI child.  It contains a dialog which contains a form.
- This form has a command bar and a docking pane.  It contains several panes, each of which contains a form.
- These sub-forms have a docking pane with one pane.  This pane also contains a form.
- This sub-form contains a command bar and a docking pane.  The docking pane contains several panes, which are all picture boxes.

In the code, the only form that has its MDIParent set is the MDI child.  None of the sub-forms or sub-sub-forms have it set.

What happens is that there are no title bars on the panes at all.  Furthermore, I cannot move the panes around - I cannot get those blue arrows which allow me to dock the panes somewhere else.  Strangely enough, on one of the sub-forms, which has the panes arranged in tabs, nothing happens when I click on one of the tabs to change the pane, even though I have verified that the events are getting sent.

All of this works fine in VB6.
Brian Justice
Senior Developer Corepoint Health.
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 31 December 2010 at 4:09pm
Very hard to say without your project.  I'll point out some things you might have missed.

few things:

In MDI you need:

            foreach (Control ctrl in this.Controls)
            {
                if (ctrl is MdiClient)
                {                                                                       
                    CommandBars.SetMDIClient(ctrl.Handle.ToInt32());
                }
            }

            MDIDockingPaneManager.SetCommandBars (CommandBars.GetDispatch());
            MDIDockingPaneManager.Options.ThemedFloatingFrames = true;

            foreach (Control ctrl in this.Controls)
            {
                if (ctrl is MdiClient)
                {                                                                       
                    MDIDockingPaneManager.SetMDIClient(ctrl.Handle.ToInt32());
                }
            }

to see stickers you must show them:

            MDIDockingPaneManager.Options.ShowDockingContextStickers = true;
            MDIDockingPaneManager.Options.StickerStyle = XtremeDockingPane.DockingContextStickerStyle.StickerStyleVisualStudio2005;
            MDIDockingPaneManager.Options.AlphaDockingContext = true;

each subform with CB and DP must have this set before panes created and after CB created:
ChildDockingPaneManager.SetCommandBars (CommandBars.GetDispatch());

for mdi child there is a different way needed for our controls, for normal forms\not mdi child this is not needed:

When .NET switch from standard frame to MDI Child Frame it recreates window and kills our CommandBars and panes. Please read through this entire post as it contains several important things you need to do to get the Commandbars 100% functional. Hope this helps.

Here is a work around for so you can work with it like normal, meaning simply drop the CB or DP on your MDI Child form and use code below (note there is other ways around it, but all are much messier)

//***********************
//********Note 1**********
//***********************

//Add a public method in MDI child:

    public void RestoreCommandBars()
    {
      CommandBars.AttachToWindow(this.Handle.ToInt32());

      CommandBars.Icons = frmMain.Instance.ImageManager.Icons;

      CommandBar StandardBar = CommandBars.Add("Standard", XTPBarPosition.xtpBarTop);
      CommandBarPopup ControlNew = (CommandBarPopup)AddButton(StandardBar.Controls, XTPControlType.xtpControlSplitButtonPopup, ID.FILE_NEW_PROJECT, "New");
      AddButton(ControlNew.CommandBar.Controls, XTPControlType.xtpControlButton, ID.FILE_NEW_PROJECT, "New Project");
      AddButton(ControlNew.CommandBar.Controls, XTPControlType.xtpControlButton, ID.FILE_NEW_BLANK, "New Blank Solution");
      CommandBarPopup ControlItem = (CommandBarPopup)AddButton(StandardBar.Controls, XTPControlType.xtpControlSplitButtonPopup, ID.PROJECT_NEW, "New Item");
      AddButton(ControlItem.CommandBar.Controls, XTPControlType.xtpControlButton, ID.PROJECT_NEW, "Add New Item");
      AddButton(ControlItem.CommandBar.Controls, XTPControlType.xtpControlButton, ID.PROJECT_EXIST, "Add Existin&g Item...");
      AddButton(ControlItem.CommandBar.Controls, XTPControlType.xtpControlButton, ID.PROJECT_ADD_CLASS, "Add Class...");
    }

        public void RestorePanes()
        {
            DockingPaneManager.AttachToWindow(this.Handle.ToInt32());
            DockingPaneManager.SetCommandBars (CommandBars.GetDispatch());

            DockingPaneManager.ScaleMode = XtremeDockingPane.XTPScaleMode.xtpScalePixel;

            Pane PaneProperties;
            PaneProperties = this.DockingPaneManager.CreatePane(1, 210, 120, XtremeDockingPane.DockingDirection.DockLeftOf, null);
            PaneProperties.Title = "Properties";

            rtfTextBox.Text = "This is a MDI Child form that contains a Docking Pane.  The procedure to accomplish this is different than simply displaying a 'normal' child form.  To see how to display a Docking Pane on a 'normal' child form click the 'Child Form with Docking Pane' button on the toolbar.";
        }

//And call it after you create MDI child:
      frmDocument frmDocument = new frmDocument();
      frmDocument.MdiParent = this;
      frmDocument.Show();
      frmDocument.Text = "Document " + lDocumentCount.ToString();
      frmDocument.RestoreCommandBars();
      frmDocument.RestorePanes();

//***********************
//********Note 2**********
//***********************

Another important thing to consider is .NET will rename our CommandBars Resize event to "ResizeEvent". So you will want to use "ResizeEvent" instead of "Resize".

this.axCommandBars.ResizeEvent += new System.EventHandler(this.axCommandBars_ResizeEvent);

    private void CommandBars_ResizeEvent(object sender, EventArgs e)
    {
      System.Diagnostics.Debug.Write("CB Resize");
    }

//***********************
//********Note 3**********
//***********************

If you use ImageManager you will want to keep it on the main form and reference it. Just have your image manager on the main MDI form and reference it in child like this:

CommandBars.Icons = frmMain.Instance.ImageManager.Icons;


//***********************
//********Note 4**********
//***********************

If you set EnableGroups to True don't set child form state to Maximized, the Workspace will manually reposition it to allow create multiple groups. If set to Maximized you will see allot of flicker. You might then have to manually resize the child windows to fill the workspace and hide the titlebar.  
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 02 January 2011 at 9:19pm
Did this help you?
Back to Top
bjust View Drop Down
Groupie
Groupie


Joined: 22 December 2010
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote bjust Quote  Post ReplyReply Direct Link To This Post Posted: 03 January 2011 at 11:53am
Thanks for your detailed message.  Unfortunately, I am already doing all of this in the code.  Can you give me your email address so that I can email you the project?  My company won't allow me to post it to a public forum since it contains proprietary code.
Brian Justice
Senior Developer Corepoint Health.
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 03 January 2011 at 12:52pm
just send it to support@codejock.com

are you sure you clean\rebuild all in your project and have to load commandbars or panes called?
Back to Top
bjust View Drop Down
Groupie
Groupie


Joined: 22 December 2010
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote bjust Quote  Post ReplyReply Direct Link To This Post Posted: 04 January 2011 at 2:33pm
I found the problem.  We are evaluating a VB6 to C# converter.  The converter generated incorrect code for setting the .Options properties on the panes.  Once I fixed it, everything works.  Sorry to have bothered you.
Brian Justice
Senior Developer Corepoint Health.
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 04 January 2011 at 3:10pm
glad you found the problem
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.