如题

解决方案 »

  1.   

    Private Sub Command1_Click()
        MsgBox CStr(Screen.Height \ Screen.TwipsPerPixelY) '屏幕高度
        MsgBox CStr(Screen.Width \ Screen.TwipsPerPixelX) '屏幕宽度
    End Sub不用api,这样就可以
      

  2.   

    这样有的机器会出现问题的,所以必须要用api得到.
      

  3.   

    用api实现的例子。Option Explicit
    Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
    Const HORZRES = 8
    Const VHORZRES = 10
    Const BITSPIXEL = 12
    Private Sub Command1_Click()
        Dim H As Long, V As Long, Color As Long
        H = GetDeviceCaps(Form1.hdc, HORZRES) '屏幕宽度
        V = GetDeviceCaps(Form1.hdc, VHORZRES) '屏幕高度
        Color = GetDeviceCaps(Form1.hdc, BITSPIXEL) '屏幕颜色位数
        MsgBox "当前分辨率为:" + CStr(H) + "*" + CStr(V) + "," + CStr(Color) + "位色"
        
    End Sub
      

  4.   

    那如何用api得到TwipsPerPixelX和TwipsPerPixelY的值呢,我想要转换后的那种高度和宽度!
      

  5.   

    为什么?
    TwipsPerPixelX和TwipsPerPixelY的调用不会出现问题呀,没必要用api
      

  6.   

    如果你要进行坐标转换的话,那么ClientToScreen和ScreenToClient是你需要的函数
      

  7.   

    直接用screen.TwipsPerPixelX就可得出TwipsPerPixelX的值
      

  8.   

    Screen.TwipsPerPixelX的值是永远都不会出问题的吗?Screen.width是会出问题的.另外,ClientToScreen函数怎么用,能否给出例子?