gpt4 book ai didi

wpf - 如何在 WPF 中应用 WS_EX_TRANSPARENT?

转载 作者:行者123 更新时间:2023-12-04 13:40:08 25 4
gpt4 key购买 nike

我想做一个启动画面,不能用鼠标/UI点击/选择。

我该如何申请

 Win32.ExtendedWindowStyles.WS_EX_TRANSPARENT

在 Windows Presentation Foundation 窗口上?

In Forms I'd do this .

最佳答案

    public const int WS_EX_TRANSPARENT = 0x00000020;
public const int GWL_EXSTYLE = (-20);

[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hwnd, int index);

[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);



public static void ToTransparentWindow(this Window x)
{

x.SourceInitialized +=
delegate
{
// Get this window's handle
IntPtr hwnd = new WindowInteropHelper(x).Handle;

// Change the extended window style to include WS_EX_TRANSPARENT
int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);

SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
};


}

关于wpf - 如何在 WPF 中应用 WS_EX_TRANSPARENT?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2408196/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com