VB6.0 如何检测到系统变更分辨率?
windowsXP 原来是1024*768的分辨率,运行窗体。之后修改windows分辨率,窗体自动做反映。
之前我都是在Form_Load里,用GetSystemMetrics来取当前windows的分辨率,在设Form的位置,但是修改分辨率后,需要重启窗体,很麻烦。求助。

解决方案 »

  1.   

    不知道你需要如何“设Form的位置”。比较简单的方案用个定时器,定期检查。
    如果有最大化的窗体,那么直接在 Form_Resize 中进行检查。
      

  2.   

    Private Sub Form_Load()
    Timer1.Tag = Screen.Width / Screen.TwipsPerPixelX
    End SubPrivate Sub Timer1_Timer()
    a = Screen.Width / Screen.TwipsPerPixelX
    If a <> Timer1.Tag Then
    MsgBox "分辨率改变了!"
    Timer1.Tag = Screen.Width / Screen.TwipsPerPixelXEnd If
    End Sub
      

  3.   

    分辩率改变将会激发 Form_Paint 在此检测即可Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    Const SM_CXSCREEN = 0
    Const SM_CYSCREEN = 1
    Dim ScnW&, ScnH&
    Private Sub Form_Load()
       ScnW = GetSystemMetrics(SM_CXSCREEN): ScnH = GetSystemMetrics(SM_CYSCREEN)
    End Sub
    Private Sub Form_Paint()
       If Screen.Width / Screen.TwipsPerPixelX <> ScnW Or Screen.Height / Screen.TwipsPerPixelY <> ScnH Then
          ScnW = Screen.Width / Screen.TwipsPerPixelX
          ScnH = Screen.Height / Screen.TwipsPerPixelY
          MsgBox "分辩率已改变"
       End If
    End Sub
      

  4.   

    用不着Timer,在Form_Paint事件中处理即可。
    偶就不信屏幕分辨率都改了还不激活Form_Paint事件!