gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 19:44:08 25 4
gpt4 key购买 nike

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

我正在执行通常的设置边界样式为无,并填充范围,如果我只是手动启动应用程序,它会完美地工作。

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

有没有人以前遇到过这个问题,或者知道可能的解决方法。

最佳答案

我之前也这样做过:

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 年的...

关于c# - 在启动任务栏上覆盖全屏 C# 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19486472/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com