'如果左上角点恒为背景色,则代码修改如下即可
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 Command1_Click()
End
End Sub
Private Sub Form_Load()
'以左上角点为背景色透明窗体
Dim rtn As Long
Me.AutoRedraw = True
rtn = GetWindowLong(hwnd, -20)
rtn = rtn Or &H80000
SetWindowLong hwnd, -20, rtn
SetLayeredWindowAttributes hwnd, Me.Point(15, 15), 0, 1
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'移动窗体
If Button = 1 Then
Me.Left = Me.Left + X - Me.Width / 2
Me.Top = Me.Top + Y - Me.Height / 2
End If
End Sub
[ 本帖最后由 xzlxzlxzl 于 2014-12-17 03:14 编辑 ]
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 Command1_Click()
End
End Sub
Private Sub Form_Load()
'以左上角点为背景色透明窗体
Dim rtn As Long
Me.AutoRedraw = True
rtn = GetWindowLong(hwnd, -20)
rtn = rtn Or &H80000
SetWindowLong hwnd, -20, rtn
SetLayeredWindowAttributes hwnd, Me.Point(15, 15), 0, 1
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'移动窗体
If Button = 1 Then
Me.Left = Me.Left + X - Me.Width / 2
Me.Top = Me.Top + Y - Me.Height / 2
End If
End Sub
[ 本帖最后由 xzlxzlxzl 于 2014-12-17 03:14 编辑 ]