在启动任务栏上覆盖全屏C#应用程序

时间:2013-10-21 04:49:40

标签: c# winforms taskbar

我使用在启动时运行的visual studio编写了一个Kiosk风格的C#应用​​程序,应该扩展到全屏并覆盖任务栏。

我正在设置通常的设置边框样式为无,并填充范围,如果我只是手动启动应用程序,它可以正常工作。

当应用程序在启动时启动时(通过开始菜单中的启动文件夹中的快捷方式),任务栏最终位于程序之上并单击表单上的某个位置不会使表单返回到顶部。

之前是否有人遇到此问题,或者知道可能的解决方法。

2 个答案:

答案 0 :(得分:3)

我还做了另一次:

public class Screensize
{
    /// <summary>
    /// Selected Win AI Function Calls
    /// </summary>

    public class WinApi
    {
        [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
        public static extern int GetSystemMetrics(int which);

        [DllImport("user32.dll")]
        public static extern void
            SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter,
                         int X, int Y, int width, int height, uint flags);

        private const int SM_CXSCREEN = 0;
        private const int SM_CYSCREEN = 1;
        private static IntPtr HWND_TOP = IntPtr.Zero;
        private const int SWP_SHOWWINDOW = 64; // 0x0040

        public static int ScreenX
        {
            get { return GetSystemMetrics(SM_CXSCREEN); }
        }

        public static int ScreenY
        {
            get { return GetSystemMetrics(SM_CYSCREEN); }
        }

        public static void SetWinFullScreen(IntPtr hwnd)
        {
            SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);
        }
    }

    /// <summary>
    /// Class used to preserve / restore state of the form
    /// </summary>
    public class FormState
    {
        private FormWindowState winState;
        private FormBorderStyle brdStyle;
        private bool topMost;
        private Rectangle bounds;

        private bool IsMaximized = false;

        public void Maximize(Form targetForm)
        {
            if (!IsMaximized)
            {
                IsMaximized = true;
                Save(targetForm);
                targetForm.WindowState = FormWindowState.Maximized;
                targetForm.FormBorderStyle = FormBorderStyle.None;
                targetForm.TopMost = false;
                WinApi.SetWinFullScreen(targetForm.Handle);
            }
        }

        public void Save(Form targetForm)
        {
            winState = targetForm.WindowState;
            brdStyle = targetForm.FormBorderStyle;
            topMost = targetForm.TopMost;
            bounds = targetForm.Bounds;
        }

        public void Restore(Form targetForm)
        {
            targetForm.WindowState = winState;
            targetForm.FormBorderStyle = brdStyle;
            targetForm.TopMost = topMost;
            targetForm.Bounds = bounds;
            IsMaximized = false;
        }
    }

然后打电话给你的表格:

screensize.Maximize(this)

我认为你的意思是

现在我看到这篇文章是从2013年开始的......

答案 1 :(得分:0)

解决方法:启动时,杀死explorer.exe - 您不需要它 - &gt;任务栏消失了。 需要时,使用任务管理器

启动它