VB图片怎么透明?
- 提问者网友:回忆在搜索
- 2021-04-23 22:30
- 五星知识达人网友:轻熟杀无赦
- 2021-04-23 23:27
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long '设置欲控制窗体参数APIPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long '设置欲控制窗体透明度APIPrivate 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 = &H80000Private Const GWL_EXSTYLE = (-20)Private Const LWA_ALPHA = &H2Private Const LWA_COLORKEY = &H1
Private Function SetTransperancy(ByVal hwnd As Long) Dim rtn As Long rtn = GetWindowLong(hwnd, GWL_EXSTYLE) rtn = rtn Or WS_EX_LAYERED SetWindowLong hwnd, GWL_EXSTYLE, rtnEnd Function
Private Function SetTransperancyCulor(ByVal hwnd As Long) Dim rtn As Long rtn = GetWindowLong(hwnd, GWL_EXSTYLE) rtn = rtn Or WS_EX_LAYERED SetWindowLong hwnd, GWL_EXSTYLE, rtn '//要去掉的颜色是&HFFFFFF SetLayeredWindowAttributes hwnd, &HFFFFFF, 0, LWA_COLORKEYEnd Function
Private Sub Form_Load()
App.TaskVisible = False Me.BackColor = &HFFFFFF Call SetTransperancyCulor(Me.hwnd)
End Sub