如何使一个窗体全屏化,覆盖任务栏?
如题
[解决办法]
main中这么写:
Hwnd = FindWindow( "HHTaskBar ", null);
if (Hwnd != 0)
{
//hide taskbar
ShowWindow(Hwnd, SW_HIDE);
Application.Run(new MainFrorm());
ShowWindow(Hwnd, SW_SHOW);
}
声明这样写:
[DllImport( "coredll ", EntryPoint = "FindWindow ")]
public static extern int FindWindow(
string lpWindowName,
string lpClassName
);
public const int SW_SHOW = 5;
public const int SW_HIDE = 0;
[DllImport( "coredll ", EntryPoint = "ShowWindow ")]
public static extern int ShowWindow(
int hwnd,
int nCmdShow
);
[解决办法]
声明api:
public const int SPI_SETWORKAREA = 47;
[DllImport( "coredll ", EntryPoint = "SystemParametersInfo ")]
public static extern int SystemParametersInfo(
int uAction,
int uParam,
ref Rectangle lpvParam,
int fuWinIni
);
添加引用:
using System.Runtime.InteropServices;
使用如下:
SystemParametersInfo(SPI_SETWORKAREA, 0, ref Screen.PrimaryScreen.Bounds,
SPIF_UPDATEINIFILE);
[解决办法]
<DllImport( "coredll ", EntryPoint := "SystemParametersInfo ")>
[解决办法]
翻译 成 vb.net
声明api:
Public Const SPI_SETWORKAREA As Integer = 47
<DllImport( "coredll ", EntryPoint := "SystemParametersInfo ")> _
Public Shared Function SystemParametersInfo(ByVal uAction As Integer, ByVal uParam As Integer, ByRef lpvParam As Rectangle, ByVal fuWinIni As Integer) As Integer
End Function
添加引用:
Imports System.Runtime.InteropServices
使用如下:
SystemParametersInfo(SPI_SETWORKAREA, 0, Screen.PrimaryScreen.Bounds, SPIF_UPDATEINIFILE)
[解决办法]
或这样:
this.StartPosition = FormStartPosition.Manual;
this.TopMost = true;
this.Location = new Point(0, 0);
this.Size = Screen.FromHandle(this.Handle).Bounds.Size;