vb 窗体透明效果(控件不透明)

vb 窗体透明效果(控件不透明),第1张

概述'窗体透明,控件不透明的代码:Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias
'窗体透明,控件不透明的代码:Private Declare Function getwindowlong lib "user32" Alias "getwindowlongA" (ByVal hwnd As Long,ByVal nIndex As Long) As LongPrivate Declare Function SetwindowLong lib "user32" Alias "SetwindowLongA" (ByVal hwnd As Long,ByVal nIndex As Long,ByVal DWNewLong As Long) As LongPrivate Declare Function SetlayeredWindowAttributes lib "user32" (ByVal hwnd As Long,ByVal crKey As Long,ByVal bAlpha As Byte,ByVal DWFlags As Long) As LongPrivate Const WS_EX_layered = &H80000Private Const GWL_EXSTYLE = (-20)Private Const LWA_Alpha = &H2Private Const LWA_colorKEY = &H1
 
Private Sub Form_Load()   Me.Backcolor = &HFF0000   Dim rtn As Long   Dim borderStyler   borderStyler = 0   rtn = getwindowlong(hwnd,GWL_EXSTYLE)   rtn = rtn Or WS_EX_layered   SetwindowLong hwnd,GWL_EXSTYLE,rtn   SetlayeredWindowAttributes hwnd,&HFF0000,LWA_colorKEYEnd Sub
 
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
‘窗体逐渐变透明:'添加一个PicturebBox,依它为容器添加一个shape,背景色设为蓝色'添加一个时钟控件Private Declare Function getwindowlong lib "user32" Alias "getwindowlongA" (ByVal hwnd As Long,ByVal DWFlags As Long) As LongConst WS_EX_layered = &H80000Const GWL_EXSTYLE = (-20)Const LWA_Alpha = &H2Const LWA_colorKEY = &H1Dim tmd As LongPrivate Sub Form_Load()ShowShape1.Backcolor = &H80000002Shape1.BackStyle = 1tmd = 255Timer1.Interval = 50Shape1.WIDth = Picture1.WIDth     SetwindowLong hwnd,WS_EX_layered     SetlayeredWindowAttributes hwnd,tmd,LWA_Alpha '越少越透明,限制0-255End SubPrivate Sub Timer1_Timer()On Error Resume Nexttmd = tmd - 1SetlayeredWindowAttributes hwnd,LWA_AlphaShape1.WIDth = Shape1.WIDth - Picture1.WIDth / 255If tmd < 0 Then  Timer1.Enabled = False  MsgBox "OK!"End IfEnd Sub
总结

以上是内存溢出为你收集整理的vb 窗体透明效果(控件不透明)全部内容,希望文章能够帮你解决vb 窗体透明效果(控件不透明)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1288284.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存