VB的不规则窗体问题,请大神解答
朋友给过我一个代码可以做出不规则的窗体,即为:窗体透明控件不透明,我使用了IMG控件去加载PNG图片达到做出漂亮界面的效果,但这个代码有几个缺点,1:他会挡在其他窗体前面...
朋友给过我一个代码可以做出不规则的窗体,即为:窗体透明控件不透明,我使用了IMG控件去加载PNG图片达到做出漂亮界面的效果,但这个代码有几个缺点,
1:他会挡在其他窗体前面,这点让我很苦恼。
2:他没办法精确的画出半的效果,也就是加入你在PNG图片里面加入一个阴影或者描边的半透明效果,结果淡色的阴影就变成了一片灰,这让我无法做出完美的3D界面效果。
希望前辈们能够提供一个更好的代码,最好是能够解答一下,非常感谢! 展开
1:他会挡在其他窗体前面,这点让我很苦恼。
2:他没办法精确的画出半的效果,也就是加入你在PNG图片里面加入一个阴影或者描边的半透明效果,结果淡色的阴影就变成了一片灰,这让我无法做出完美的3D界面效果。
希望前辈们能够提供一个更好的代码,最好是能够解答一下,非常感谢! 展开
展开全部
vb窗体透明鼠标穿透效果源代码
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 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Const WS_EX_TRANSPARENT As Long = &H20&
Private Sub Form_Load()
Dim rtn As Long
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED 'Or WS_EX_TRANSPARENT '加上or 后面的会加上穿透效果
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, vbWhite, 100, LWA_ALPHA '200是透明度 0-250
End Sub
我网上找的,没试过
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 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Const WS_EX_TRANSPARENT As Long = &H20&
Private Sub Form_Load()
Dim rtn As Long
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED 'Or WS_EX_TRANSPARENT '加上or 后面的会加上穿透效果
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, vbWhite, 100, LWA_ALPHA '200是透明度 0-250
End Sub
我网上找的,没试过
追问
我是要求控件不透明啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询