Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Integer
Declare Function FillRect Lib "USER32" (ByVal hDC As Integer, lpRect As RECT, ByVal hBrush As Integer) As Integer
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Integer) As Integer'''''''''''''''''''''''''''''''''''''''''''''''
Type RECT
    left As Integer
    top As Integer
    right As Integer
    bottom As IntegerEnd Type  Private Sub Form_Paint()
Dim Color As Integer
    Dim hBrush As Integer
    Dim OldMode As Integer
    Dim RetVal  As Integer
    Dim StepSize As Integer
    Dim X As Integer
    Dim FillArea As RECT
    OldMode = Me.ScaleMode
    Me.ScaleMode = 3
    
    StepSize = 1 + Me.ScaleHeight / 80
    Color = 255
    FillArea.left = 0
    FillArea.right = Me.ScaleWidth
    FillArea.top = 0
    FillArea.bottom = StepSize
    For X = 1 To 80
    hBrush = CreateSolidBrush(RGB(0, 255, Color))
    RetVal = FillRect(Me.hDC, FillArea, hBrush)
    RetVal = DeleteObject(hBrush)
    Color = Color - 4
    
    If Color < 0 Then
     Color = 0
     FillArea.top = FillArea.bottom
    End If
     
    FillArea.bottom = FillArea.bottom + StepSize
    Next
    Me.ScaleMode = OldMode
End SubRetVal = FillRect(Me.hDC, FillArea, hBrush)有溢出错误
请问如何解决
谢谢

解决方案 »

  1.   

    Option Explicit'''''''''''''''''''''''''''''''''''''''''''''''
    Private Type RECT
        left As Long
        top As Long
        right As Long
        bottom As LongEnd Type
    Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    Private Declare Function FillRect Lib "USER32" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
      Private Sub Form_Paint()
        Dim Color As Long
        Dim hBrush As Long
        Dim OldMode As Long
        Dim RetVal  As Long
        Dim StepSize As Long
        Dim X As Long
        Dim FillArea As RECT
        OldMode = Me.ScaleMode
        Me.ScaleMode = 3
        
        StepSize = 1 + Me.ScaleHeight / 80
        Color = 255
        FillArea.left = 0
        FillArea.right = Me.ScaleWidth
        FillArea.top = 0
        FillArea.bottom = StepSize
        For X = 1 To 80
        hBrush = CreateSolidBrush(RGB(0, 255, Color))
        RetVal = FillRect(Me.hDC, FillArea, hBrush)
        RetVal = DeleteObject(hBrush)
        Color = Color - 4
        
        If Color < 0 Then
         Color = 0
         FillArea.top = FillArea.bottom
        End If
         
        FillArea.bottom = FillArea.bottom + StepSize
        Next
        Me.ScaleMode = OldMode
    End Sub