My MDI isn't starting right

早过忘川 提交于 2019-12-13 07:59:33

问题


My C# MDI Application starts in program.cs, which looks like this:

namespace APRSTW
{
    static class Program
    {
        public static Form parentForm;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            parentForm = new MainAPRSTW();//<-so I can reference this form as a parent in other .cs files.
            Application.Run(parentForm);
        }
    }
}

The constructor for MainAPRSTW looks like this:

public MainAPRSTW()
{
    frmSplash objfrmSplash = new frmSplash();
    objfrmSplash.ShowDialog();

    //windows init
    InitializeComponent();

    //Initialize the program
    InitProgram();

}//close main

I have posted a PNG screen capture of what happens when the program runs at

http://www.Blandranch.net/Files/Capture.PNG (case matters after .net)

You are seeing outlines of the child forms and the holes are text boxes and groups. I never see the parent form.

What am I doing wrong?


回答1:


I think showing the splash screen is the issue. If you tell Application that you are starting with 1 form you can't then jump to another form before the first one is shown. What you should probably do is show your splash screen from Application.Run and then have your splash screen show your MDI form.



来源:https://stackoverflow.com/questions/11786120/my-mdi-isnt-starting-right

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!