欢迎光临 Rick 's BLOG
日志首页  | C# .Net编程  | 原创作品  | 生活点滴  | C\C++相关  | 多媒体相关※ERMP  | VB相关  | 其它运维与编程  |  留言簿
get the PIII processor serial number (psn) VC_VB的混合编译(一) 原理片
未知  用VB写MOUSE穿透的窗体
[ 发布日期:22年前 (2005-04-06) ]   [ 来自:本站原创 ] [分类:VB相关]
MOUSE穿透,就是写一个半透明的窗体,点击窗体的时候它下面的程序产生事件。  
  
---------------------------------------------------------------  
[复制到剪贴板]
 
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const
WS_EX_LAYERED = &H80000
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Form_Load()

Dim Ret As Long
Ret
= GetWindowLong(Me.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong Me
.hWnd, GWL_EXSTYLE, Ret
'Set the opacity of the layered window to 200
SetLayeredWindowAttributes Me.hWnd, 0, 200, LWA_ALPHA
End Sub
?>

---------------------------------------------------------------  
 
再加上WS_EX_TRANSPARENT就能穿透鼠标了:  
[复制到剪贴板]
 
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const
WS_EX_LAYERED = &H80000
Const WS_EX_TRANSPARENT As Long = &H20&
Private Declare Function
GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Form_Load()

Dim Ret As Long
Ret
= GetWindowLong(Me.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED Or WS_EX_TRANSPARENT
SetWindowLong Me
.hWnd, GWL_EXSTYLE, Ret
'Set the opacity of the layered window to 200
SetLayeredWindowAttributes Me.hWnd, 0, 200, LWA_ALPHA
End Sub
?>
如果文章对您有帮助,给个赞赏吧!
引用通告地址 (0):
复制引用地址https://www.rickw.cn/trackback/64
复制引用地址https://www.rickw.cn/trackback/64/GBK
[ 分类:VB相关  | 查看:4162 ]

暂时没有评论,快来发表一个评论吧。
发表评论
作者:   用户:[访客] 
评论:

表  情
禁止表情 | 禁止UBB | 禁止图片 | 识别链接
对不起,你没有权限上传附件!
验证:
 
PoweredBy R-Blog V1.00 © 2004-2026 WWW.RICKW.CN, Processed in second(s) , 7 queries    京ICP备17058477号-5