Ign*_*mez 8 c# fullscreen windows-mobile windows-ce visual-studio-2008
我有我的应用程序,并希望它以全屏模式运行,没有任务栏.我发现了如何隐藏窗口栏,但是当我启动我的应用程序时,它不会覆盖Windows任务栏的空间,尽管最后一个是隐藏的.
我发现了这个,但它没有用.我无法找到关于wince的例子.我有FormBorderStyle = None,而WindowsState =最大化
解:
我找到了一种方法.一个重要的提示是让WindowState = Normal(我花了一些时间才发现这个问题).如果您有WindowState = Maximized,则无法将Form的高度设置为最大显示高度.
我写了这段代码来探测它,它工作正常.是一个带有两个按钮的表单:button1(全屏)和button2(恢复默认屏幕)
public partial class Form1 : Form
{
public Form1(){
InitializeComponent();
}
[DllImport("Coredll")]
internal static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
[DllImport("coredll.dll")]
internal static extern bool EnableWindow(IntPtr hwnd, Boolean bEnable);
[DllImport("coredll.dll")]
private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, bool repaint);
public static bool EnableTaskBar(Boolean enable)
{
IntPtr hwnd;
hwnd = FindWindow("HHTaskBar", "");
if (enable) SetHHTaskBar();
else HideHHTaskBar();
return EnableWindow(hwnd, enable);
}
public static void HideHHTaskBar()
{
IntPtr iptrTB = FindWindow("HHTaskBar", null);
MoveWindow(iptrTB, 0, Screen.PrimaryScreen.Bounds.Height,
Screen.PrimaryScreen.Bounds.Width, 26, true);
}
public static void SetHHTaskBar()
{
IntPtr iptrTB = FindWindow("HHTaskBar", null);
MoveWindow(iptrTB, 0, 294,
Screen.PrimaryScreen.Bounds.Width, 26, true);
}
private void button1_Click(object sender, EventArgs e)
{
EnableTaskBar(false);
this.Width = Screen.PrimaryScreen.Bounds.Width;
this.Height = Screen.PrimaryScreen.Bounds.Height;
this.Left = 0;
this.Top = 0;
}
private void button2_Click(object sender, EventArgs e)
{
EnableTaskBar(true);
}
}
Run Code Online (Sandbox Code Playgroud)
希望它能帮助其他人解决同样的问题!
谢谢您的帮助!
隐藏任务栏后,显式设置表单的大小和位置:
myForm.Width = Screen.PrimaryScreen.Bounds.Width;
myForm.Height = Screen.PrimaryScreen.Bounds.Height;
myForm.Left = 0;
myForm.Top = 0;
Run Code Online (Sandbox Code Playgroud)