简体   繁体   English

启动任务栏上最大化的外部应用程序(全屏)

[英]Start external application maximized over taskbar (fullscreen)

How can i start external application in "fullscreen" mode (without borders and over taskbar)? 如何以“全屏”模式(无边框和任务栏上方)启动外部应用程序? And is it possible to do this using only .Net Framework library? 是否可以仅使用.Net Framework库来执行此操作? Thanks for help. 感谢帮助。

try to use next 尝试使用下一个

this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.Bounds = Screen.PrimaryScreen.Bounds;
this.TopMost = true;

in case of PInvoke try this code 如果是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);

And call this 并称之为

 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);

As Raymond Chen suggests , the best way to create a fullscreen window that covers up the taskbar is simply by creating a fullscreen window without a border. 正如Raymond Chen所建议的那样 ,创建覆盖任务栏的全屏窗口的最佳方法就是创建无边框的全屏窗口。

Since your question is tagged C++, I'll assume you can translate this code into its .NET equivalent: 由于您的问题被标记为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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM