mcyh吧 关注:73贴子:3,003
  • 7回复贴,共1

无视控件的全窗口内鼠标坐标获取

只看楼主收藏回复

度娘。真是亲娘


IP属地:浙江来自iPhone客户端1楼2015-06-17 08:01回复
    无视控件的全窗口内鼠标坐标获取(很方便)
    Option Explicit
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    Private Type POINTAPI
    x As Long
    y As Long
    End Type
    ————————————————
    Private Sub Timer1_Timer()
    Dim P As POINTAPI
    GetCursorPos P '获取鼠标在屏幕中的位置
    ScreenToClient Me.hwnd, P '转换为本窗体的坐标
    Dim t As Boolean
    t = P.x >= 0 And P.y >= 0 And P.x < Me.Width / Screen.TwipsPerPixelX And P.y <= Me.Height / Screen.TwipsPerPixelY
    If t Then Me.Caption = "x=" & P.x & "y=" & P.y '按像素显示坐标
    'If t Then Me.Caption = "x=" & P.x * Screen.TwipsPerPixelX & "y=" & P.y * Screen.TwipsPerPixelY '按缇显示坐标
    End Sub


    IP属地:浙江来自iPhone客户端2楼2015-06-17 08:01
    回复
      三楼插广告


      IP属地:浙江来自iPhone客户端4楼2015-06-17 08:02
      回复
        ,
           哦呵呵呵呵呵呵呵呵呵呵呵


        IP属地:天津来自Android客户端5楼2015-06-24 07:22
        回复
          强烈建议楼主研究VB.net


          来自Android客户端6楼2015-07-01 17:15
          收起回复