VB 如何让窗口显示在鼠标指针旁边
我需要在打开窗口UserForm1的时候,让窗口显示在鼠标位置,鼠标位置不一定在前一个窗体上,可能是在屏幕上的任意位置.请高手指点!...
我需要在打开窗口UserForm1的时候,让窗口显示在鼠标位置,鼠标位置不一定在前一个窗体上,可能是在屏幕上的任意位置.
请高手指点! 展开
请高手指点! 展开
2个回答
展开全部
Option Explicit
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Form_Load()
Dim n As POINTAPI
GetCursorPos n
Form1.Left = n.x * 15
Form1.Top = n.y * 15
End Sub
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Form_Load()
Dim n As POINTAPI
GetCursorPos n
Form1.Left = n.x * 15
Form1.Top = n.y * 15
End Sub
展开全部
Private Declare Function getCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Private Type POINTAPI '声明数据类型
x As Long
y As Long
End Type
Dim z As POINTAPI '声明变量
Private Sub Form_Load()
getCursorPos z
pos = "Pos: x:" & z.x & " y:" & z.y '显示x坐标和y坐标
Me.Move z.x * 15, z.y * 15
End Sub
Private Type POINTAPI '声明数据类型
x As Long
y As Long
End Type
Dim z As POINTAPI '声明变量
Private Sub Form_Load()
getCursorPos z
pos = "Pos: x:" & z.x & " y:" & z.y '显示x坐标和y坐标
Me.Move z.x * 15, z.y * 15
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询