我用一个Timer,定时取得屏幕某点的颜色,Timer1.inteval设置为50 ms,当运行一段时间(大概15分钟)之后,程序就象没反应一样,界面上的控件不可见,如果移动鼠标的话,但仍然勉强可以看到鼠标移动之处的界面(如最大化,最小化,关闭按钮)是不是没有释放场景?请各位大侠请点,谢谢!程序如下:Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Sub Timer1_Timer()    Dim colorMe As Single, rgbRed As Single, rgbGreen As Single, rgbBlue As Single
        '获取屏幕X=100,Y=100处的颜色值
        colorMe = GetPixel(GetDC(0), 100, 100)           
        Picture1.BackColor = colorMe
        Debug.Print ReleaseDC(hwnd, hdc)
End Sub

解决方案 »

  1.   

    hdc=GetDC(0)
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
      

  2.   

    增加: RE = ReleaseDC(hwnd, hdc)
    去掉:    Debug.Print ReleaseDC(hwnd, hdc) 
      

  3.   

    Private Sub Timer1_Timer() 
        Dim HdcScreen as long
        Dim colorMe As Single, rgbRed As Single, rgbGreen As Single, rgbBlue As Single 
           '获取屏幕X=100,Y=100处的颜色值 
            HdcScreen=GetDc(0) '获取
            colorMe = GetPixel(HdcScreen, 100, 100)          
           Picture1.BackColor = colorMe 
           DeleteDC HdcScreen '删除 
    End Sub 
      

  4.   

    Private Sub Timer1_Timer()
        Dim colorMe As Single, rgbRed As Single, rgbGreen As Single, rgbBlue As Single 
        Dim hdc As Long    hdc = GetDC(0)
        colorMe = GetPixel(hdc, 100, 100)          
        Picture1.BackColor = colorMe
        ReleaseDC(0, hdc)
    End Sub 
      

  5.   

    谢谢各位。
    改下面这句后好了
    ReleaseDC 0, hdc