문제

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