VB窗口透明问题
PrivateDeclareFunctionSetWindowLongLib"user32"Alias"SetWindowLongA"(ByValhwndAsLong,B...
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
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_ALPHA = &H2
'Const LWA_COLORKEY = &H1
Private Sub Form_Load()
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes Me.hwnd, 0, 150, LWA_ALPHA '150为透明度(0-255)
End Sub
请分别讲述一下怎样实现字体、图片、控件不透明 展开
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_ALPHA = &H2
'Const LWA_COLORKEY = &H1
Private Sub Form_Load()
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes Me.hwnd, 0, 150, LWA_ALPHA '150为透明度(0-255)
End Sub
请分别讲述一下怎样实现字体、图片、控件不透明 展开
展开全部
SetLayeredWindowAttributes Me.hwnd, 0, 150, LWA_ALPHA '150为透明度(0-255)
不能让控件单独透明。只能随你的窗体半透明
SetLayeredWindowAttributes Me.hwnd, &Hff00ff, 0, &H1
这样会让是&HFF00FF(VB常数vbMagenta的值)一样颜色,都透明
你可以试试以下代码
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
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_ALPHA = &H2
'Const LWA_COLORKEY = &H1
Private Sub Form_Load()
me.backcolor=&Hff00ff
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes Me.hwnd, &HFF00FF, 0, &H1
End Sub
不能让控件单独透明。只能随你的窗体半透明
SetLayeredWindowAttributes Me.hwnd, &Hff00ff, 0, &H1
这样会让是&HFF00FF(VB常数vbMagenta的值)一样颜色,都透明
你可以试试以下代码
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
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_ALPHA = &H2
'Const LWA_COLORKEY = &H1
Private Sub Form_Load()
me.backcolor=&Hff00ff
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes Me.hwnd, &HFF00FF, 0, &H1
End Sub
追问
大哥,我只需要让窗体半透明,其他的不透明啊,你的理解纯粹南辕北辙啊!!!
追答
那个更容易
你只要
SetLayeredWindowAttributes Me.hwnd, 0, 128, &H2
就行了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询