VB窗口跟鼠标走
PrivateDeclareFunctionShellExecuteLib"shell32.dll"Alias"ShellExecuteA"(ByValhwndAsLon...
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
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 Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Form_Load()
Dim myval
myval = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
Private Sub Timer1_Timer()
Dim Point As POINTAPI
GetCursorPos Point
Form1.Left = Point.X
Form1.Cls
Print CStr(Point.X)
Print CStr(Point.Y)
Form1.Top = Point.Y
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 Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Form_Load()
Dim myval
myval = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
Private Sub Timer1_Timer()
Dim Point As POINTAPI
GetCursorPos Point
Form1.Left = Point.X
Form1.Cls
Print CStr(Point.X)
Print CStr(Point.Y)
Form1.Top = Point.Y
End Sub
为什么这样窗口不会跟着鼠标`怎么让他跟着鼠标` 展开
1个回答
展开全部
这样改:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
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 Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Form_Load()
Dim myval
myval = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
Private Sub Timer1_Timer()
Dim mPOINT As POINTAPI
GetCursorPos mPOINT
MoveWindow Me.hwnd, mPOINT.x, mPOINT.y, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, 1 '移动窗口
Form1.Cls
Print CStr(mPOINT.x)
Print CStr(mPOINT.y)
End Sub
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
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 Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Form_Load()
Dim myval
myval = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
Private Sub Timer1_Timer()
Dim mPOINT As POINTAPI
GetCursorPos mPOINT
MoveWindow Me.hwnd, mPOINT.x, mPOINT.y, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, 1 '移动窗口
Form1.Cls
Print CStr(mPOINT.x)
Print CStr(mPOINT.y)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询