Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2007

Tip: Looking for answers? Try searching our database.

After hide model form, parent form may change z-order(may not topm

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fluxray - 23 Mar 2007 14:01 GMT
Objective is simple. Show Form1 first and maximize it (can make observation
easier), then after click button1, show form2 as modal dialog.
When hide form2 by click button2, the expected behavior is that form2 hides
and form1 becomes the topmost form.

The funny thing is that, sometimes after hide form2, some kind of blinking
will be seen.
You will find something like form1 become transparent-like for 0.2-2 second
or just go to the back,
and the window (e.g., Visual Studio) which was right behind form1 will show
up.
Form1 will comeback to top most again very soon after this z-order switch.
But it also may just never come back, becoming the 2nd topmost form. The
Visual Studio IDE will be the top most window. Need to use alt-tab to get
form1 back.

Can anyone explain this? Thanks.

Slower pc can make it more easy to observe. But this also happen on fast pc.

Part of the C# Code (excluding designer code and some other non-crutial
code):
       [STAThread]
       static void Main()
       {
           Application.EnableVisualStyles();
           Application.SetCompatibleTextRenderingDefault(false);
           Application.Run(new Form1());
       }

   public partial class Form1 : Form
   {
       private Form2 f;

       public Form1()
       {
           InitializeComponent();

           f = new Form2();
       }

       private void button1_Click(object sender, EventArgs e)
       {
           DialogResult d = f.ShowDialog(this);
       }
   }

   public partial class Form2 : Form
   {
       public Form2()
       {
           InitializeComponent();
       }

       private void button2_Click(object sender, EventArgs e)
       {
           this.Hide();
       }
   }
Manish Bafna - 24 Mar 2007 10:50 GMT
Try setting the modal form's(form2) TopMost to False and setting its Owner
property to the parent(form1) Form.

   Form2 f = new Form2();

    f.TopMost = false;

    f.Owner = this;

    f.Show();
Signature

If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

> Objective is simple. Show Form1 first and maximize it (can make observation
> easier), then after click button1, show form2 as modal dialog.
[quoted text clipped - 55 lines]
>         }
>     }
Fluxray - 28 Mar 2007 03:05 GMT
Thanks Manish but seems it is not working. And I do need showdialog to make
sure the parent form is disabled.

> Try setting the modal form's(form2) TopMost to False and setting its Owner
> property to the parent(form1) Form.
[quoted text clipped - 66 lines]
> >         }
> >     }
VJ - 28 Mar 2007 17:32 GMT
Hi.. This has been a problem for us. We choose to give quick navigate
buttons so the user can swtich back. I have looked around, was never able to
get a answer.
If you do find some, would like to learn!

VJ

> Thanks Manish but seems it is not working. And I do need showdialog to
> make
[quoted text clipped - 80 lines]
>> >         }
>> >     }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.