如题,程序是做出来了,利用Topmost="True"把窗口置顶,然后利用
private void MainWindow_SourceInitialized(object sender, EventArgs e)
{
IntPtr hwnd = new WindowInteropHelper(this).Handle;
uint extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
}
private const int WS_EX_TRANSPARENT = 0x20;
private const int GWL_EXSTYLE = -20;
[DllImport("user32", EntryPoint = "SetWindowLong")]
private static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
[DllImport("user32", EntryPoint = "GetWindowLong")]
private static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
实现窗口的穿透,效果也是OK的.唯一的问题是,游戏帧率会大打折扣。就类似焦点不在游戏程序上,导致程序刷新率降低。
有没有大佬指导一下原因,还有没有解决办法,或者新的方案规避这个问题。
private void MainWindow_SourceInitialized(object sender, EventArgs e)
{
IntPtr hwnd = new WindowInteropHelper(this).Handle;
uint extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
}
private const int WS_EX_TRANSPARENT = 0x20;
private const int GWL_EXSTYLE = -20;
[DllImport("user32", EntryPoint = "SetWindowLong")]
private static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
[DllImport("user32", EntryPoint = "GetWindowLong")]
private static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
实现窗口的穿透,效果也是OK的.唯一的问题是,游戏帧率会大打折扣。就类似焦点不在游戏程序上,导致程序刷新率降低。
有没有大佬指导一下原因,还有没有解决办法,或者新的方案规避这个问题。