如果播放器是全屏的话,你可以截获播放视频的那个控件的鼠标消息,并把消息发送给桌面,这样就可以实现透过半透明的窗体操作桌面的效果,给你举个例子
这个例子是截获窗体的鼠标消息,你可以换成相应的控件
窗体无边框,大小位置为桌面工作区(不包括任务栏)的大小位置,窗体半透明
using System.Runtime.InteropServices;
[DllImport("user32.dll", EntryPoint = "PostMessage")]
public static extern int PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", EntryPoint = "GetWindow")]
public static extern IntPtr GetWindow(IntPtr hwnd, int wCmd);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
const int WM_MOUSEMOVE = 0x0200;
const int WM_MOUSELEAVE = 0x02A3;
const int WM_SETCURSOR = 0x0020;
const int WM_LBUTTONDOWN = 0x0201;
const int WM_LBUTTONUP = 0x0202;
const int WM_LBUTTONDBLCLK = 0x0203;
const int WM_RBUTTONDOWN = 0x0204;
const int WM_RBUTTONUP = 0x0205;
const int WM_RBUTTONDBLCLK = 0x0206;
const int GW_CHILD = 5;
IntPtr workingAreaHandle;
//获得桌面工作区的句柄
IntPtr GetDesktopListViewHandle()
{
IntPtr hResult;
hResult = FindWindow("ProgMan", null);
hResult = GetWindow(hResult, GW_CHILD);
hResult = GetWindow(hResult, GW_CHILD);
return hResult;
}
private void Form1_Load(object sender, EventArgs e)
{
workingAreaHandle = GetDesktopListViewHandle();
this.FormBorderStyle = FormBorderStyle.None;
this.Location = new Point(0, 0);
this.Size = new Size(Screen.PrimaryScreen.WorkingArea.Width,Screen.PrimaryScreen.WorkingArea.Height);
this.Opacity = 0.5f;
}
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_MOUSEMOVE ||
m.Msg == WM_MOUSELEAVE ||
m.Msg == WM_SETCURSOR ||
m.Msg == WM_LBUTTONDOWN ||
m.Msg == WM_LBUTTONUP ||
m.Msg == WM_LBUTTONDBLCLK ||
m.Msg == WM_RBUTTONDOWN ||
m.Msg == WM_RBUTTONUP ||
m.Msg == WM_RBUTTONDBLCLK)
{
PostMessage(workingAreaHandle, m.Msg, m.WParam, m.LParam);
return;
}
base.WndProc(ref m);
}
温馨提示:内容为网友见解,仅供参考