如何在“全屏”模式下启动外部应用程序(没有边框和任务栏)?是否可以仅使用.Net Framework库来完成此操作?谢谢你的帮助。
答案 0 :(得分:3)
尝试使用下一个
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.Bounds = Screen.PrimaryScreen.Bounds;
this.TopMost = true;
如果是PInvoke,请尝试使用此代码
public static IntPtr HWND_TOPMOST = (IntPtr)(-1);
public const int SWP_SHOWWINDOW = 0x0040;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,int x,int y,int cx,int cy, UInt32 uFlags);
并称之为
IntPtr handle = this.Handle // or Handle to another window
SetWindowPos(handle, HWND_TOPMOST, 0, 0, Screen.PrimaryScreen.Bounds.Right,
Screen.PrimaryScreen.Bounds.Bottom, SWP_SHOWWINDOW);
答案 1 :(得分:3)
作为Raymond Chen suggests,创建覆盖任务栏的全屏窗口的最佳方法是创建一个没有边框的全屏窗口。
由于您的问题标记为C ++,我假设您可以将此代码转换为其.NET等效代码:
HWND CreateFullscreenWindow(HWND hwnd)
{
HMONITOR hmon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO mi = { sizeof(mi) };
if (!GetMonitorInfo(hmon, &mi)) return NULL;
return CreateWindow(TEXT("static"),
TEXT("something interesting might go here"),
WS_POPUP | WS_VISIBLE,
mi.rcMonitor.left,
mi.rcMonitor.top,
mi.rcMonitor.right - mi.rcMonitor.left,
mi.rcMonitor.bottom - mi.rcMonitor.top,
hwnd, NULL, g_hinst, 0);
}