把窗體的formborderstyle設(shè)為formborderstyle.none
using system.runtime.interopservices;
private const uint ws_ex_layered = 0x80000;
private const int ws_ex_transparent = 0x20;
private const int gwl_style = (-16);
private const int gwl_exstyle = (-20);
private const int lwa_alpha = 0x2;
[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
);
[dllimport("user32", entrypoint = "setlayeredwindowattributes")]
private static extern int setlayeredwindowattributes(
intptr hwnd,
int crkey,
int balpha,
int dwflags
);
/// <summary>
/// 使窗口有鼠標穿透功能
/// </summary>
public void canpenetrate()
{
uint intextemp = getwindowlong(this.handle, gwl_exstyle);
uint oldgwlex = setwindowlong(this.handle, gwl_exstyle, ws_ex_transparent | ws_ex_layered);
setlayeredwindowattributes(this.handle, 0, 100, lwa_alpha);
}
要時窗體恢復(fù)正常,只要執(zhí)行以下語句:
this.formborderstyle = formborderstyle.none;
新聞熱點
疑難解答
圖片精選