Can you please take a look at following app to see what I am doing wrong?
Download App(WinFormsStarts)
What I want to do is running multiple modal forms AND keeping the MainApp form accessible until finishing all required modals.As you can see from the application, as soon as you run the program the MainApp form (in Maximized windows State) and the Welcome form pops up.
till here everything is fine but when I chose the "Start New Project" the QuickStart form pops up BUT the MainApp minimize which is not meant to be.
This issue also happen when user chose the "Start Existing Project" then the MainApp minimize again and the Open dialog appear on the screen.
Here are the codes ,as well:
1- MainApp
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WinFormStarts
- {
- public partial class MainApp : Form
- {
- public MainApp()
- {
- InitializeComponent();
- }
- private void MainApp_Load(object sender, EventArgs e)
- {
- Welcome welcomeForm = new Welcome();
- welcomeForm.ShowDialog();
- }
- }
- }
2- Welcome Form
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WinFormStarts
- {
- public partial class Welcome : Form
- {
- public Welcome()
- {
- InitializeComponent();
- }
- private void btnExisting_Click(object sender, EventArgs e)
- {
- this.Hide();
- OpenFileDialog dlg = new OpenFileDialog();
- dlg.ShowDialog();
- }
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- Application.Exit();
- }
- private void btnNew_Click(object sender, EventArgs e)
- {
- this.Hide();
- QuickStart qs = new QuickStart();
- qs.ShowDialog();
- }
- }
- }
3- QuickStart Form
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WinFormStarts
- {
- public partial class QuickStart : Form
- {
- public QuickStart()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- Application.Exit();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
Please let me know what is wrong with this apss. Thanks for your time in advanced
VulpesPosted Oct 26, 2011, 8:47 AM
VulpesPosted Oct 26, 2011, 2:18 PM
However, it'll probably still work if you replace 'this.Owner' by 'this' when calling qs.ShowDialog.
Behrouz HosseiniPosted Oct 26, 2011, 1:31 PM
Just as always you reply perfectly to questions.I can gues that the parameter value specify the owner of the forms but the only thing which I not sure is the different between welcomeForm.ShowDialog(this); and qs.ShowDialog(this.Owner);?
How come you used the "this" for first form but "this.Owner" for the second one?Is that because the QtartForm is calling from the outside of owner class?
Thanks again for you time