【发布时间】:2011-02-22 11:30:03
【问题描述】:
如何在不退出电影播放器的全屏模式的情况下全屏播放电影时显示一个窗口?我只想让窗口出现在电影的顶部。我知道这是可能的,因为 yahoo messeger 每次向您显示 pearson 已登录或退出时都会这样做,而且我确信还有其他程序也这样做,但我现在不记得了。
它可以在 C/C++ mfc、win api 、 c# 、 wpf 中,它不重要。
【问题讨论】:
如何在不退出电影播放器的全屏模式的情况下全屏播放电影时显示一个窗口?我只想让窗口出现在电影的顶部。我知道这是可能的,因为 yahoo messeger 每次向您显示 pearson 已登录或退出时都会这样做,而且我确信还有其他程序也这样做,但我现在不记得了。
它可以在 C/C++ mfc、win api 、 c# 、 wpf 中,它不重要。
【问题讨论】:
只需显示带有 z 顺序的窗口,将其置于全屏窗口的顶部。我想你可以通过调用SetWindowPos 传递HWND_TOP 来做到这一点。像这样的:
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
您可能还想包含SWP_NOACTIVATE,或者可能包含其他一些SWP_*** 选项。您可以检查 SetWindowPos 函数中的 uFlags 参数以获取不同的 SWP_*** 消息。
【讨论】:
C# 使用 user32.dll 的 SetForegroundWindow()
更多关于* C# Force Form Focus
// Sets the window to be foreground
[DllImport("User32")]
private static extern int SetForegroundWindow(IntPtr hwnd);
// Activate or minimize a window
[DllImportAttribute("User32.DLL")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private const int SW_SHOW = 5;
private const int SW_MINIMIZE = 6; private const int SW_RESTORE = 9;
private void ActivateApplication(string strAppName)
{
Process[] pList = Process.GetProcessesByName(strAppName);
if (pList.Length > 0)
{
ShowWindow(pList[0].MainWindowHandle, SW_RESTORE);
SetForegroundWindow(pList[0].MainWindowHandle);
}
}
【讨论】:
SetForegroundWindow 将使播放器退出全屏模式,BringWindowToTop 将不起作用。如果窗口来自与视频播放器相同的应用程序,则所有其他方法都可以工作,但我需要将一个窗口放入来自另一个应用程序的视频播放器(全屏)。
【讨论】: