I know it is possible - somehow through SetWindowLong API or managed property of WPF's Window class at the moment of window's creation... but how to do that exactly I do not know. I simply cannot find the information of how to set style of a window so it could NOT receive any system messages about mouse click on it and any click would go through the window to the underlying windows.

Does anyone know that style code or something?

有帮助吗?

解决方案

Set the WS_EX_TRANSPARENT flag for the window's extended style. It makes the window transparent to mouse clicks.

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

int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
WinAPI.SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);

其他提示

WS_EX_TRANSPARENT not enough.

Need WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_TOPMOST;

And

SetLayeredWindowAttributes(hWnd, 0, 150, LWA_ALPHA); 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top