启动画面后,主窗口出现在其他窗口后面 [英] Main window appears behind other windows after splash screen

查看:35
本文介绍了启动画面后,主窗口出现在其他窗口后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有闪屏的 Windows 窗体应用程序.当我运行应用程序时,初始屏幕显示正常,然后消失,应用程序的主窗体已加载.

I have a Windows Forms Application with a splash screen. When I run the application the splash screen shows up fine, disappears and the main form for the application is loaded.

但是,当我加载主窗体时,它会出现在包含该应用程序的 Windows 资源管理器目录下.下面是一段代码,先运行启动画面,然后运行主窗体.

However, when I load the main form it appears beneath the Windows Explorer directory which contains the application. Here is a segment of code that runs the splash screen and then the main form.

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {        
        public Form1()
        {
            Thread t = new Thread(new ThreadStart(SplashStart));
            t.Start();
            Thread.Sleep(1500);
            InitializeComponent();
            t.Abort();
        }        
        public void SplashStart()
        {
            Application.Run(new SplashScreen());
        }
    }
}   

如何让 Form1 显示在所有其他窗口之上?

How can I get Form1 to show above all other windows?

推荐答案

Form1.Activate(); 

这应该使它成为焦点并放在前面.

This should make it the focus and bring to front.

MSDN 链接:系统窗体窗体激活

这篇关于启动画面后,主窗口出现在其他窗口后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆