vb.net控件不透明 vb设置控件透明度

vb.net 窗体背景透明 而控件不透明!PNG透明时 , 在窗体上的颜色是这个窗体的BackColor
可以将窗体的TransparencyKey属性设为BackColor
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 Const WS_EX_LAYERED = H80000
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TRANSPARENT = H20
Private Const LWA_ALPHA = H2
Private Const LWA_COLORKEY = H1
Private Sub Form_Load()
Dim rtn As Long, ctrol As Control
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_TRANSPARENT
SetWindowLong hwnd, GWL_EXSTYLE, rtn
Me.Show
DoEvents
For Each ctrol In Me.Controls
ctrol.Refresh
Next
'SetLayeredWindowAttributes hwnd, 0, 100, LWA_ALPHA'100值可调,0-255之间,越小透明度越高
'SetLayeredWindowAttributes hwnd, RGB(0, 0, 0), 0, LWA_COLORKEY'将窗体上的黑颜色去掉
End Sub
vb.net picture控件本身不透明 就像这样 我不想要小人下面的黑块..这个小人是透明的,PictureBox1.BackColor=Color.Transparent
用PS处理成gif格式的就可以了,vb不支持PNG图片 , 但是gif是可以的
vb 中怎么实现 窗体透明 但控件不透明 求 代码 谢谢先把窗体的颜色换成其它的vb.net控件不透明 , 然后在用SetLayeredWindowAttributes函数设置窗体的背景色为透明 , 如果觉得窗体的标题栏没透明而不美观的话 , 可以把窗体的BorderStyle设为0 。代码举例(在窗体代码区中加入)vb.net控件不透明: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()
Me.BackColor
=
RGB(210,
210,
210)
'背景透明
Dim
crKey
As
Long,
bAlpha
As
Byte,
dwFlags
As
Long
Call
SetWindLong
dwFlags
=
1
'1
只有
crKey
指定的颜色才透明,忽略
bAlpha
参数
crKey
=
Me.BackColor
'窗体中设为透明的颜色
SetLayeredWindowAttributes
Me.hWnd,
crKey,
bAlpha,
dwFlags
End
Sub Private
Sub
SetWindLong()
'为调用
SetLayeredWindowAttributes
做准备
Dim
ExsTyle
As
Long
Const
WS_EX_Layered
=
H80000,
GWL_ExsTyle
=
-20
ExsTyle
=
GetWindowLong(Me.hWnd,
GWL_ExsTyle)
ExsTyle
=
ExsTyle
Or
WS_EX_Layered
SetWindowLong
Me.hWnd,
GWL_ExsTyle,
ExsTyle
End
Sub
【vb.net控件不透明 vb设置控件透明度】关于vb.net控件不透明和vb设置控件透明度的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读