在Form 中创建一个Label 控件,并使用以下内容使其透明:
Me.TransparencyKey = Color.Gray ' or any other color.
Me.BackColor = TransparencyKey
Me.FormBorderStyle = FormBorderStyle.None
会做这样的事情:
要使您的窗口对鼠标透明,请 PInvoke GetWindowLong 和 SetWindowLong:
<DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function GetWindowLong( _
ByVal hWnd As IntPtr, _
ByVal nIndex As Integer) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function SetWindowLong( _
ByVal hWnd As IntPtr, _
ByVal nIndex As Integer, _
ByVal dwNewLong As IntPtr) As Integer
End Function
然后在您的Form_Load() 中添加以下内容:
Dim hwnd As IntPtr = Me.Handle
Dim extendedStyle As Integer = GetWindowLong(hwnd, GWL_EXSTYLE)
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle Or WS_EX_TRANSPARENT)
常量:
Const WS_EX_TRANSPARENT As Integer = &H20
Const GWL_EXSTYLE As Integer = -20