We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

childFrameBarManager / MDI Form --> constructor called twice

Hi, attached you´ll find a little sample app with two forms (MDI parent/child). Press the New-Button, and you can see that the form2 constructor (MDI child) is called TWO times. When closing the MDI child the Dispose method is also called TWO times. Now remove childFrameBarManager1 from form2 and start again. As you can see, only ONE constructor/dispose-call occur - the way it should be :)) . My BIG(!) problem is, that my working app has an ActiveX control in form2. When I close my app (sometimes when I close the MDI child), I´ll get an Exception whitch states, that an operation is not possible because there´s no window handle. You can reproduce this behaviour with a "simple" WebBrowser control (from toolbar) on form2. Create a few MDI childs and then close the app. Depending on whatever you´ll get exceptions or the app will simply hang up. Any help appreciated. Thanks in advance and Greetings from germany, (and sorry for my english) Marc

4 Replies

AD Administrator Syncfusion Team November 18, 2002 02:06 PM UTC

Marc, The reason the constructor is being called is because our framework creates a dummy instance of the Child Form (for use in displaying the disabled menu items, when the child form is not visible or active). In any case, I dropped a WebBrowser control on the child Form and ran the app. But didn't notice the exception you were mentioning. Could you attach an app with an ActiveX control on the child form and causing the exception? Thanks Praveen Ramesh Essential Tools Development Team > Hi, > > attached you´ll find a little sample app with two forms (MDI parent/child). Press the New-Button, and you can see that the form2 constructor (MDI child) is called TWO times. When closing the MDI child the Dispose method is also called TWO times. > > Now remove childFrameBarManager1 from form2 and start again. As you can see, only ONE constructor/dispose-call occur - the way it should be :)) . > > My BIG(!) problem is, that my working app has an ActiveX control in form2. When I close my app (sometimes when I close the MDI child), I´ll get an Exception whitch states, that an operation is not possible because there´s no window handle. > > You can reproduce this behaviour with a "simple" WebBrowser control (from toolbar) on form2. Create a few MDI childs and then close the app. Depending on whatever you´ll get exceptions or the app will simply hang up. > > Any help appreciated. > Thanks in advance and > Greetings from germany, > (and sorry for my english) > > Marc


MV Marc Velten November 21, 2002 08:48 AM UTC

Hi Praveen, sorry for the delay! Attached you'll find a modified version of my previous sample. Form2 contains a user control "myBrowser1" which ist simply a combination of a panel, a textbox and a WebBrowser control (assembly DemoControlLib). Run the app, create a few form2 windows and then close the app. Now you "should" see the mentioned exception (Screenshot1.jpg). That´s a BIG problem in our main project. When I replace the user control with an WebBrowser control (form3.cs), no exception is thrown. So, my previous statement was wrong, sorry. But here you can see another little problem. After a click on "New Form3" you'll initially see two windows (Screenshot2.jpg). After a repaint of the MDI parent the grey "shadow" of the dummy instance is gone. Thanks in advance Marc


AD Administrator Syncfusion Team November 21, 2002 02:36 PM UTC

Marc, Thanks for the sample. 1) Regarding the WebBrowser control throwing an exception when closing the child Form, I figured that this is a bug in the framework. If you did something like this... // ChildForm has the MyBrowser control ChildForm childForm = new ChildForm(); childForm.Dispose(); ... you will see that the same exception occurs. If you decide to test this, make sure that the above childForm doesn't have a ChildFrameBarManager in it. So, here is a good way to workaround this issue: In the MyBrowser designer, set the Visibility of the WebBrowser to false. Then in MyBrowser class, override the following method: protected override void OnVisibleChanged(EventArgs e) { // The idea is to delay making the web browser visible until the parent is visible. if(this.Visible) this.axWebBrowser1.Visible = true; base.OnVisibleChanged(e); } This seems to workaround the problem. 2) Regarding the stray child Form being shown, I found that this seems to be fixed in Evertte (the next .Net version, soon to be released). However, for now, you can workaround this too, by invlidating the Mdi client region after showing the child, as follows: private void barItem1_Click(object sender, System.EventArgs e) { Form3 form3 = new Form3(); form3.MdiParent = this; form3.Show(); // Will redraw MdiClient after showing. this.MdiClient.Invalidate(); } private Control MdiClient { get { foreach(Control control in this.Controls) if(control is MdiClient) return control; return null; } } Let me know if these work for you. Regards, Praveen Ramesh


MV Marc Velten November 22, 2002 04:09 AM UTC

Hi Praveen, it works! Great job, thank you very much. Greetings from Germany Marc

Loader.
Live Chat Icon For mobile
Up arrow icon