herasmussen
Tue Sep 19 02:50:02 CDT 2006
Hi Linda,
Thank you for your reply. Yes, this is quite close to what I want. I had
come up with something along the same lines, but it leaves a few problems:
1. The popup form (Form3 in your sample) stays on top, not just on top of
the parent (Form2) but also any other MDI childs (Form4). So in a situation
with many MDI child forms of which several has a popup form, the popup forms
will cover it all.
2. Keyboard navigation between MDI windows doesn't work when the parent
(Form1) is disabled. Clicking the disabled parent doesn't activate the popup,
but rather the other MDI child.
In the button click handler in the sample you set the popup form's Owner
property. What is achieved by that?
I'm considering using a borderless control for the popup form, and then use
the theme rendering classes to draw a fake window in stead. What do you think
of that?
That way the fake form will follow the MDI child as any other control on the
form, including minimizing with the parent and going behind other MDI child
forms.
Sincerely,
Henrik Rasmussen
"Linda Liu [MSFT]" wrote:
> Hi Henrik,
>
> I agree with what Bob said that a form will either be modal or modeless. If
> you want a form to be modal for one specific form and modeless for other
> forms, you may do this by code.
>
> The following is a sample. I create a Windows application project and add
> four forms into the project. They're called Form1, Form2, Form3 and Form4
> respectively. Form1 is the MDI parent form. Form2 and Form4 are MDI child
> form. Form3 is the popup form for Form2. I add a button called button1 in
> Form2. When the button1 is clicked, Form3 is shown. Below is the code in
> Form1and Form2.
>
> private void Form1_Load(object sender, EventArgs e)
> {
> Form2 frm2 = new Form2();
> Form4 frm4 = new Form4();
> frm2.MdiParent = this;
> frm4.MdiParent = this;
> frm2.Show();
> frm4.Show();
> }
>
> public partial class Form2 : Form
> {
> Form3 frm = null;
> private void button1_Click(object sender, EventArgs e)
> {
> if (frm == null)
> {
> frm = new Form3();
> this.frm.FormClosed += new
> FormClosedEventHandler(frm_FormClosed);
> }
> frm.Owner = this.MdiParent;
> frm.TopLevel = true;
> frm.ShowInTaskbar = false;
> frm.Show();
> // disable Form2, so that it cannot get focus until Form3 is
> closed
> this.Enabled = false;
> }
>
> void frm_FormClosed(object sender, FormClosedEventArgs e)
> {
> frm.FormClosed -= new FormClosedEventHandler(frm_FormClosed);
> frm = null;
> // When Form3 is closed, enable Form2 again
> this.Enabled = true;
> }
> }
>
> Hope this helps. If the above sample is not what you want, please feel free
> to let me know.
>
>
> Sincerely,
> Linda Liu
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
>
http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>