在VB中如何获得整个屏幕的大小和坐标?
 谢谢。

解决方案 »

  1.   

    screen的大小,screen.width screen.height
    获取鼠标的位置需要用api,好像是getcursorpos
      

  2.   

    screen不可以直接用吧,我用了试了一下,说没有定义变量,在用它之前要声明其它的东东吗?
     谢谢。
      

  3.   


    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Type POINTAPI
            x As Long
            y As Long
    End TypePrivate Sub Form_Load()Dim pos As POINTAPI
    GetCursorPos posDebug.Print Screen.Width
    Debug.Print Screen.Height
    Debug.Print pos.x
    Debug.Print pos.yEnd Sub
    不用引用什么,仔细看看是不是写错了。
      

  4.   

    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Type POINTAPI
            x As Long
            y As Long
    End TypePrivate Sub Form_Load()
    Timer1.Interval = 500
     Timer1.Enabled = TrueEnd SubPrivate Sub Timer1_Timer()
     
    Dim pos As POINTAPI
    GetCursorPos pos
    Label1.Caption = Screen.Width & "   " & Screen.Height & Chr(13) & "   " & pos.x & "    " & pos.y
    End Sub
      

  5.   

    我仔细看了,没有写错,我是这样用的
    Dim x As Long
      x= Screen.Width
      x= Screen.Height 
     报错说Screen变量没有定义
      

  6.   


    晕啊
    把X和Y搞清楚。。
    Dim x As Long
    Dim Y As Longx= Screen.Width
      x= Screen.Height ‘错
    为:Y=Screen.Height