vc 鼠标穿透

先说一下,VC6.0要先更新SDK,不然编译不通过,建议使用VS2008


BOOL SetTransparent(HWND hDlg, BOOL bTransparent)
{
	LONG lStyle;
	lStyle = GetWindowLong(hDlg, GWL_EXSTYLE);

	if (bTransparent)
	{
		SetWindowLong(hDlg, GWL_EXSTYLE, lStyle | WS_EX_TRANSPARENT | WS_EX_LAYERED);
		SetLayeredWindowAttributes(hDlg, 0, 255, LWA_ALPHA); //设置半透明
		SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
		return TRUE;
	}
	else
	{
		lStyle &= ~WS_EX_TRANSPARENT;
		SetWindowLong(hDlg, GWL_EXSTYLE, lStyle);
		SetLayeredWindowAttributes(hDlg, 0, 255, LWA_ALPHA);
		SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
		return FALSE;
	}
	
}

BOOL CdsdfsdDlg::OnInitDialog()
{
	SetTransparent(this->m_hWnd,TRUE);
}


你可能感兴趣的:(vc 鼠标穿透)