关于VB窗体透明的问题
这是窗体透明的代码,有一个问题是,黑色不能完全去掉,请看图片'+++++++++++++++++++++++++形状窗体(函数声明)+++++++++++++++Priv...
这是窗体透明的代码,有一个问题是,黑色不能完全去掉,请看图片
'+++++++++++++++++++++++++形状窗体(函数声明)+++++++++++++++
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1
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 GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function GetCursorPos Lib "user32" ( _
lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
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 LWA_COLORKEY = &H1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Const LWA_ALPHA = &H2
'++++++++++++++++++++++++++子程序++++++++++++++++++++++++
Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
Me.BackColor = RGB(0, 0, 0)
proper = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
proper = proper Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, proper
SetLayeredWindowAttributes Me.hwnd, RGB(0, 0, 0), 100, LWA_COLORKEY
End Sub 展开
'+++++++++++++++++++++++++形状窗体(函数声明)+++++++++++++++
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1
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 GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function GetCursorPos Lib "user32" ( _
lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
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 LWA_COLORKEY = &H1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Const LWA_ALPHA = &H2
'++++++++++++++++++++++++++子程序++++++++++++++++++++++++
Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
Me.BackColor = RGB(0, 0, 0)
proper = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
proper = proper Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, proper
SetLayeredWindowAttributes Me.hwnd, RGB(0, 0, 0), 100, LWA_COLORKEY
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询