W
Wim Verbeke
Hi everyone,
We are currently developing an application in C# which has MDI forms. Each
MDI form has a detach-button which removes the form from its parent and
displays it as a regular form.
In .NET, you can use the System.Windows.Forms.Form.MdiParent property.
Everything seems to work when regular .NET controls are part of the MDI
form.
However, if there's an ActiveX control on the form, it loses its parent and
gets drawn somewhere on the screen, floating, not part of the MDI parent and
not part of the MDI form. This is the case with for example the Internet
Explorer ActiveX (shdocvw), the Remote Desktop ActiveX (msrdp) and probably
a lot of others. We did not have that problem with a third-party component,
which seems to remember its direct parent. I guess we forgot something in
the approach on how to handle the microsoft ActiveXs.
Has anybody a clue for this problem? We already checked every property of
the AxHost and Form (container, toplevelcontrol, toplevel, parent, ...) but
they're all updated correctly after the detach. We also tried to toy with
the SetChildIndex function...
Here are the important snippets of a sample application, full source upon
request.
Project consists of 2 forms, MainForm (the MDI parent) and ChildForm (the
MDI child).
--- MainForm Load event : Start ---
this.IsMdiContainer = true;
ChildForm child = new ChildForm();
child.MdiParent = this;
child.ShowInTaskbar = false;
child.Show();
child.ChangeUrl();
--- MainForm Load event : Stop ---
ChildForm has one button (DetachButton) and an Internet Explorer ActiveX
(Microsoft Web Browser from the Microsoft Internet Controls)
--- ChildForm : DetachButton event : Start ---
private void DetachButton_Click(object sender, System.EventArgs e)
{
this.MdiParent = null;
this.ShowInTaskbar = true;
ChangeUrl();
}
--- ChildForm : DetachButton event : Stop ---
--- ChildForm : Public method : Start ---
public void ChangeUrl()
{
axWebBrowser1.Navigate("http://www.microsoft.com");
}
--- ChildForm : Public method : Stop ---
Run the application and the MDI form will show the microsoft-website. Click
detach and the form will be detached from its parent. The ActiveX starts
floating and is not part of the ChildForm anymore.
Thanks for your time!
Wim Verbeke
We are currently developing an application in C# which has MDI forms. Each
MDI form has a detach-button which removes the form from its parent and
displays it as a regular form.
In .NET, you can use the System.Windows.Forms.Form.MdiParent property.
Everything seems to work when regular .NET controls are part of the MDI
form.
However, if there's an ActiveX control on the form, it loses its parent and
gets drawn somewhere on the screen, floating, not part of the MDI parent and
not part of the MDI form. This is the case with for example the Internet
Explorer ActiveX (shdocvw), the Remote Desktop ActiveX (msrdp) and probably
a lot of others. We did not have that problem with a third-party component,
which seems to remember its direct parent. I guess we forgot something in
the approach on how to handle the microsoft ActiveXs.
Has anybody a clue for this problem? We already checked every property of
the AxHost and Form (container, toplevelcontrol, toplevel, parent, ...) but
they're all updated correctly after the detach. We also tried to toy with
the SetChildIndex function...
Here are the important snippets of a sample application, full source upon
request.
Project consists of 2 forms, MainForm (the MDI parent) and ChildForm (the
MDI child).
--- MainForm Load event : Start ---
this.IsMdiContainer = true;
ChildForm child = new ChildForm();
child.MdiParent = this;
child.ShowInTaskbar = false;
child.Show();
child.ChangeUrl();
--- MainForm Load event : Stop ---
ChildForm has one button (DetachButton) and an Internet Explorer ActiveX
(Microsoft Web Browser from the Microsoft Internet Controls)
--- ChildForm : DetachButton event : Start ---
private void DetachButton_Click(object sender, System.EventArgs e)
{
this.MdiParent = null;
this.ShowInTaskbar = true;
ChangeUrl();
}
--- ChildForm : DetachButton event : Stop ---
--- ChildForm : Public method : Start ---
public void ChangeUrl()
{
axWebBrowser1.Navigate("http://www.microsoft.com");
}
--- ChildForm : Public method : Stop ---
Run the application and the MDI form will show the microsoft-website. Click
detach and the form will be detached from its parent. The ActiveX starts
floating and is not part of the ChildForm anymore.
Thanks for your time!
Wim Verbeke