'移动窗体
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1'窗体位于最前
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
Const HWND_TOPMOST = -1
Const SWP_SHOWWINDOW = &H40'画圆角
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Integer, ByVal Y1 As Integer, ByVal X2 As Integer, ByVal Y2 As Integer, ByVal x3 As Integer, ByVal y3 As Integer) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hrgn As Long, ByVal bRedraw As Boolean) As Long'移动窗体
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ncl As Long
Dim rel As Long
If Button = 1 Then
i = ReleaseCapture()
ncl = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
    If Me.Left < 0 Then
        Me.Top = 0
        Me.Left = -1500
    End If
End If
End Sub'鼠标指向显示
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.Top <= 0 And Me.Left = -1500 Then
    Me.Top = 0
    Me.Left = 0
End If
End Sub
Private Sub Form_Load()
'最前面
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, 1  '设为最前窗体'画圆角
hround = CreateRoundRectRgn(0, 0, ScaleX(Form1.ScaleWidth, vbTwips, vbPixels), ScaleY(Form1.ScaleHeight, vbTwips, vbPixels), 15, 15)
SetWindowRgn Me.hwnd, hround, True
DeleteObject hroundEnd Sub----------------------------------------------------------
仿QQ,怎样在鼠标移出时把位置移到0,-1500 ??大家看下大代帮我补一下啊

解决方案 »

  1.   

    Option Explicit
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Type POINTAPI
        x As Long
        y As Long
    End Type
    Private Sub Timer1_Timer()
        Dim Cur As POINTAPI
        Dim cX As Long
        cX = (Me.Left + Me.Width) / Screen.TwipsPerPixelX
        GetCursorPos Cur
        If Cur.x > cX Then
            Debug.Print "出界"
        End If
           
    End Sub
      

  2.   

    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long此处报错,用户定义类型未定义
      

  3.   

    Private Type POINTAPI
        x As Long
        y As Long
    End Type
    --------------不是吗?我以写了啊!