Commandbars in MDI child form |
Post Reply |
Author | |
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
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 ... |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
Just tried with the CommandBars MDISamples:
VB6 sample works very well ! C# sample also does NOT show Commandbars on MDI child !!! |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
Can please someone from CodeJock have a look at it ???
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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; } } } |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
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 ... |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
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 ... |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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 :) |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
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 ? |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
I guess we will dig some more to see if anything can be done.
|
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
Thanks so much !!!
Please keep me up to date ... |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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(); |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
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 ? |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
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 { }; } |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
Also docking the menu/toolbar to other location does not cause redraw the client area
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
And you tried CommandBars_Resize?
|
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
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 ! |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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"); } |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
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 ! |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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 :) |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
Works with
this.axCommandBars.ResizeEvent += new System.EventHandler(this.axCommandBars_ResizeEvent); Do I have to add handler for the other events too ? |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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 |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
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... |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
so what is other problem?
And what is issue with commandbars in MDI Child? Seems everything is working... |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
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 |
|
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
|
Dear Supermario,
are you able to reproduce the problem ? |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |