展开全部
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, _
ByVal crKey As Long, ByVal bAlpha As Long, ByVal dwFlags As Long) As Long
Public Const GetWinLStyle = (-20)
Public Const WinAlpha = &H2
Public Const ColorSet = &H1
Public Const SetWinLLay = &H80000
Sub SetNewWindow(frm As picturebox, ByVal sColor As Long, ByVal sAlpha As Long) '//最好不用
Dim NewStyle As Long
If sColor = 0 Then
sColor = vbRed
Else
sColor = sColor
End If
If sAlpha = 0 Then
sAlpha = 0
Else
sAlpha = sAlpha
End If
NewStyle = GetWindowLong(frm.hWnd, GetWinLStyle)
NewStyle = NewStyle Or SetWinLLay
SetWindowLong frm.hWnd, GetWinLStyle, NewStyle
SetLayeredWindowAttributes frm.hWnd, sColor, sAlpha, ColorSet
End Sub
上面的sColor 设置透明的PCBOX颜色,sAlpha 透明度
或者可以用API
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
实现
可以在网上查查看
picturebox 的属性上修改
好象目前还没有看见有高手直接用属性修改的
一般都采用函数的方式去完成的
VB中设置图片和ASP这些网页程序不同
应该没有直接设置的方法,具体的上面我已经给你部分的代码,应该可以实现这种效果
我再给你一份代码
API声明放在模块里
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, _
ByVal crKey As Long, ByVal bAlpha As Long, ByVal dwFlags As Long) As Long
Public Const GetWinLStyle = (-20)
Public Const WinAlpha = &H2
Public Const ColorSet = &H1
Public Const SetWinLLay = &H80000
以下代码放在FORM_LOAD中
PICTUREBOX 名称为PCB
Dim NowStyle As Long
NowStyle = GetWindowLong(PCB.hWnd, GetWinLStyle) '取得当前窗口属性
Call SetWindowLong(PCB.hWnd, GetWinLStyle, NowStyle Or SetWinLLay)
'加上一个透明属性
Call SetLayeredWindowAttributes(PCB.hWnd, 0, 200, WinAlpha)
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, _
ByVal crKey As Long, ByVal bAlpha As Long, ByVal dwFlags As Long) As Long
Public Const GetWinLStyle = (-20)
Public Const WinAlpha = &H2
Public Const ColorSet = &H1
Public Const SetWinLLay = &H80000
Sub SetNewWindow(frm As picturebox, ByVal sColor As Long, ByVal sAlpha As Long) '//最好不用
Dim NewStyle As Long
If sColor = 0 Then
sColor = vbRed
Else
sColor = sColor
End If
If sAlpha = 0 Then
sAlpha = 0
Else
sAlpha = sAlpha
End If
NewStyle = GetWindowLong(frm.hWnd, GetWinLStyle)
NewStyle = NewStyle Or SetWinLLay
SetWindowLong frm.hWnd, GetWinLStyle, NewStyle
SetLayeredWindowAttributes frm.hWnd, sColor, sAlpha, ColorSet
End Sub
上面的sColor 设置透明的PCBOX颜色,sAlpha 透明度
或者可以用API
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
实现
可以在网上查查看
picturebox 的属性上修改
好象目前还没有看见有高手直接用属性修改的
一般都采用函数的方式去完成的
VB中设置图片和ASP这些网页程序不同
应该没有直接设置的方法,具体的上面我已经给你部分的代码,应该可以实现这种效果
我再给你一份代码
API声明放在模块里
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, _
ByVal crKey As Long, ByVal bAlpha As Long, ByVal dwFlags As Long) As Long
Public Const GetWinLStyle = (-20)
Public Const WinAlpha = &H2
Public Const ColorSet = &H1
Public Const SetWinLLay = &H80000
以下代码放在FORM_LOAD中
PICTUREBOX 名称为PCB
Dim NowStyle As Long
NowStyle = GetWindowLong(PCB.hWnd, GetWinLStyle) '取得当前窗口属性
Call SetWindowLong(PCB.hWnd, GetWinLStyle, NowStyle Or SetWinLLay)
'加上一个透明属性
Call SetLayeredWindowAttributes(PCB.hWnd, 0, 200, WinAlpha)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询