Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Commandbars in MDI child form
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Commandbars in MDI child form

 Post Reply Post Reply
Author
Message
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Topic: Commandbars in MDI child form
    Posted: 22 January 2010 at 10:41am
In a VisualStudio 2008 C# application I want to create a toolbar within my MDI Client form !
I also put all CommandBar code in mdiclient form load procedure - but the CommandBar in the child is not displayed !!!

Please help - it's very urgent !!!

In the form_load of the mdi client when I go through with the debugger the objects
axCommandBars.Options and axCommandBars.ActiveMenuBar are NULL !!!
This causes exceptions  

Hope this helps ...


Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 22 January 2010 at 10:50am
Just tried with the CommandBars MDISamples:

VB6 sample works very well !
C# sample also does NOT show Commandbars on MDI child !!!

Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 25 January 2010 at 6:32am
Can please someone from CodeJock have a look at it ???
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: 28 January 2010 at 3:26pm
Yes when .NET switch from standard frame to MDI Child Frame it recreates window and kill our CommandBars. You have move code where designer create CommandBars to Form_Load event.

To make this work, simply drag CommandBars control on form...you can remove it after if you wish, this just makes references getting set a lot easier.

Here is my ENTIRE code for my MDIChild form.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using XtremeCommandBars;

namespace MDIDocking
{
    /// <summary>
    /// Summary description for frmDocument.
    /// </summary>
    public class frmDocument : System.Windows.Forms.Form
    {
        private AxXtremeCommandBars.AxCommandBars CommandBars1;
        private System.ComponentModel.Container components = null;

        /// <summary>
        /// Required designer variable.
        /// </summary>

        public frmDocument()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            //
            // frmDocument
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(602, 369);
            this.Name = "frmDocument";
            this.Text = "MDI Child Document";
            this.Load += new System.EventHandler(this.frmDocument_Load);
            this.ResumeLayout(false);

        }
        #endregion

        private void frmDocument_Load(object sender, System.EventArgs e)
        {
            this.CommandBars1 = new AxXtremeCommandBars.AxCommandBars();
            ((System.ComponentModel.ISupportInitialize)(this.CommandBars1)).BeginInit();
            this.CommandBars1.Enabled = true;
            this.CommandBars1.Name = "CommandBars1";
            this.Controls.Add(this.CommandBars1);
            ((System.ComponentModel.ISupportInitialize)(this.CommandBars1)).EndInit();

            XtremeCommandBars.CommandBarControl Control;
            XtremeCommandBars.CommandBarControls Controls;

            XtremeCommandBars.CommandBarPopup ControlFile = (XtremeCommandBars.CommandBarPopup)CommandBars1.ActiveMenuBar.Controls.Add(XtremeCommandBars.XTPControlType.xtpControlPopup, 0, "&File22", -1, false);
            Controls = ControlFile.CommandBar.Controls;

            Control = Controls.Add(XtremeCommandBars.XTPControlType.xtpControlButton, ID.ID_FILE_NEW, "&New", -1, false);
            Control.DescriptionText = "Create a new document";

            Control = Controls.Add(XtremeCommandBars.XTPControlType.xtpControlButton, ID.ID_FILE_OPEN, "&Open", -1, false);
            Control.DescriptionText = "Open an existing document";
            Control = Controls.Add(XtremeCommandBars.XTPControlType.xtpControlButton, ID.ID_FILE_CLOSE, "&Close", -1, false);
            Control.DescriptionText = "Close the active document";
            Control = Controls.Add(XtremeCommandBars.XTPControlType.xtpControlButton, ID.ID_FILE_SAVE, "&Save", -1, false);
            Control.DescriptionText = "Save the active document";

            CommandBars1.ScaleMode = XtremeCommandBars.XTPScaleMode.xtpScalePixel;


        }
    }
}



Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 02 February 2010 at 9:58am
Hi SuperMario,

this "workaround" does only work as long as no other CodeJock control is on the form !
When I put a reportcontrol on the form commandbar is not shown any more !!!

Do you have any idea ?

Please help ...
Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 02 February 2010 at 12:16pm
When I create other controls the same way it seems to work !

But it makes coding even harder adding events and so on ...
ImageManager also has this problem so I would have to add images by code ?
Working this way does not make sense

Hope this problem can be fixed within the CommandBars component ?

Please let me know ...

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 February 2010 at 10:37am
Hi,
Really the icons thing isn't so bad.  Just have your image manager on the main MDI form and reference it in child like this:

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

And for adding our controls in code, not much we can do, as mentioned before, when .NET switch from standard frame to MDI Child Frame it recreates window and kill our CommandBars.  You have move code where designer create CommandBars to Form_Load event.

Again, this really isn't that big a problem.  When setting up the control, simply drop it on child as normal, add all events, set all properties, then copy\paste the form generated code to the form_load section.  So really this is only a few second cut\paste job :)
Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2010 at 10:45am
Do you see really no change to get this fixed within the CommandBars ActiveX component to use it the usual way ?
I can't image why .net kills CommandBars ?
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 February 2010 at 10:54am
I guess we will dig some more to see if anything can be done.


Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2010 at 10:54am
Thanks so much !!!
Please keep me up to date ...
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 February 2010 at 9:10am
As mentioned before, to change a form from a normal form to a MDI child .NET will first destroy it and then recreate.  I don't see how we can catch this recreate thing form our ActiveX.

Here is a work around for CommandBars so you can work with it like normal...

//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...");
        }

//And call it after you create MDI child:
            frmDocument frmDocument = new frmDocument();
            frmDocument.MdiParent = this;
            frmDocument.Show();
            frmDocument.Text = "Document " + lDocumentCount.ToString();
            frmDocument.RestoreCommandBars();
Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 04 February 2010 at 9:16am
Thanks - I will try and send you feedback !
What I do not understand why this is no problem with other CJ controls e.g. ReportControl ?
It seems "only" CommandBars has this problem - of course CommandBars is other than ReportControl
but is this the cause ?
Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 04 February 2010 at 10:11am
When I use Form_Resize to position my controls within the child form, this is not done after the child window is displayed !!!
Something like this:

        private void frmDocument_Resize(object sender, EventArgs e)
        {
            try
            {
                int left, top, right, bottom;
                axCommandBars1.GetClientRect(out left, out top, out right, out bottom);

                // Report Control des Fenstergröße anpassen
                axReportControl1.Top = top;
                axReportControl1.Height = bottom - top;
                axReportControl1.Left = left;
                axReportControl1.Width = right - left;
            }
            catch { };
        }

Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 04 February 2010 at 11:52am
Also docking the menu/toolbar to other location does not cause redraw the client area 
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 February 2010 at 1:59pm
And you tried CommandBars_Resize?
Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 04 February 2010 at 5:18pm
Do you mean to catch this event and resize other control there ?

It sounds strange but after adding this event it is not called at all !
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: 05 February 2010 at 1:57pm
I just tried both these and they work, it looks like .NET renames our Resize Event to "ResizeEvent":

        private void CommandBars_ResizeClient(object sender, AxXtremeCommandBars._DCommandBarsEvents_ResizeClientEvent e)
        {
            System.Diagnostics.Debug.Write("CB Resize");
        }

        private void CommandBars_ResizeEvent(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.Write("CB Resize");
        }
Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2010 at 2:39pm
Hi SuperMario,

when I use workaround #1 ( creating controls in Form_Load )

      private void frmTest_Load(object sender, EventArgs e)
        {
            this.axCommandBars = new AxXtremeCommandBars.AxCommandBars();
            ((System.ComponentModel.ISupportInitialize)(this.axCommandBars)).BeginInit();
            this.axCommandBars.Enabled = true;
            this.axCommandBars.Name = "axCommandBars";
            this.Controls.Add(this.axCommandBars);
            this.axCommandBars.Resize += new System.EventHandler(this.axCommandBars_Resize);
            ((System.ComponentModel.ISupportInitialize)(this.axCommandBars)).EndInit();


and also add the following functions

       private void axCommandBars_ResizeClient(object sender, AxXtremeCommandBars._DCommandBarsEvents_ResizeClientEvent e)
        {
            System.Diagnostics.Debug.Write("CB Resize");
        }

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

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


non of these gets called !
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: 05 February 2010 at 2:41pm
try
this.axCommandBars.ResizeEvent += new System.EventHandler(this.axCommandBars_ResizeEvent);

Also if you don't have #define DEBUG you won't see those messages

P.S.  You don't add handler for all 3 so of course they won't be called :)
Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2010 at 2:49pm
Works with
this.axCommandBars.ResizeEvent += new System.EventHandler(this.axCommandBars_ResizeEvent);

Do I have to add handler for the other events too ?
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: 05 February 2010 at 3:03pm
if you want to use them:

this.CommandBars.ResizeClient += new AxXtremeCommandBars._DCommandBarsEvents_ResizeClientEventHandler(this.CommandBars_ResizeClient);

Resize don't work... .NET renames ours to ResizeEvent...so use that instead
Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2010 at 3:08pm
I just struggled into other issues while testing !
Are you available for discussion tomorrow then I would try to put together a sample for demonstration ?
My problem is I will have to make a decision for using CodeJock controls in this project on Monday and till then
I will have to do all testings...
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: 05 February 2010 at 3:26pm
so what is other problem?

And what is issue with commandbars in MDI Child?  Seems everything is working...
Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2010 at 3:34pm
In short:

Seems to make differences if Workspace EnableGroups in turned on/off

ON:
- flickering in tab area when window is resized

Was caused by child window WindowState Maximized !

OFF:
- when a second child is opened initially Resize is not done - I have to manually change window size


Back to Top
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Posted: 08 February 2010 at 12:10pm
Dear Supermario,

are you able to reproduce the problem ?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 09 February 2010 at 2:35am
Hi,
 
Yes, if you set EnableGroups  to True don't set form state to Maximized - Workspace manually reposition it to allow create multiple groups.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.172 seconds.