在窗体中,加入一TextBox控件Text1,在事件Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)End Sub如果把x,y对应的坐标,转换成屏幕坐标呢?
请赐教一下。
谢谢。

解决方案 »

  1.   

    用ClientToScreen这个api函数即可实现
      

  2.   

    Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim t As POINTAPI
    t.x = x / Screen.TwipsPerPixelX
    t.y = y / Screen.TwipsPerPixelYClientToScreen Text1.hwnd, t
    Debug.Print t.x, t.y
    End Sub本例中Text控件所在的窗体的ScaleMode属性为1。
      

  3.   

    忘记加声明了。
    Private Type POINTAPI
        x As Long
        y As Long
    End Type
    Private Declare Function ClientToScreen Lib "user32" Alias "ClientToScreen" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long