失去焦点

时间:2017-11-19 18:31:59

标签: c# winforms

this link的帮助下,我制作了一个闪屏。它工作,但在spash屏幕后开始的形式不再获得焦点。我需要点击鼠标激活它

Program.cs的

static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

    //show splash
    Thread splashThread = new Thread(new ThreadStart(
        delegate
        {
            splashForm = new FormSplashScreen();
            Application.Run(splashForm);
        }
        ));

    splashThread.SetApartmentState(ApartmentState.STA);
    splashThread.Start();

    //run form - time taking operation
    FormQueryBoxMain mainForm = new FormQueryBoxMain();
    mainForm.Load += new EventHandler(mainForm_Load);
    Application.Run(mainForm);

    // Application.Run(new FormQueryBoxMain());
}

static void mainForm_Load(object sender, EventArgs e)
{
    //close splash
    if (splashForm == null)
    {
        return;
    }

    splashForm.Invoke(new Action(splashForm.Close));
    splashForm.Dispose();
    splashForm = null;
}

主要表格

private void FormMain_Load(object sender, EventArgs e)
{
    Logging.StartLogging();  //this just starts the logging  
}   

private void FormMain_VisibleChanged(object sender, EventArgs e)
{
    if (CheckLicense())
    {
        LoadTreeViewQueries();

        //Inlog
        FormGebruikerInlog ApplicatieLogIn = new FormGebruikerInlog(this, "Inlog Gebruiker");

        ApplicatieLogIn.ShowDialog(this);  --> This lost the focus.
    }
    else
    {
        LoadLicenseForm(); //Inlog voor licentie direct starten
    }
}   

ApplicatieLogIn.ShowDialog(this);表格不再具有焦点。

首先,我在FormMain_VisibleChanged站内获得了来自FormMain_Load的代码,然后在ApplicatieLogIn打开了顶部并获得了焦点 但现在我不再可能添加spashscreen了。 我怎样才能将ApplicatieLogIn重点放回去?

在ApplicatieLogIn的加载中

this.focus();this.actitive()不是技巧。

0 个答案:

没有答案