⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 axgrid.ctl

📁 VB开发的USB卸载助手源码VB开发的USB卸载助手源码VB开发的USB卸载助手源码VB开发的USB卸载助手源码
💻 CTL
📖 第 1 页 / 共 5 页
字号:
            DrawRightCols lLeftCol&, lMyColWidth&
        End If
        
        'DrawGrid               'kdq090498      replace because background was not being redrawn correctly
        RedrawAllCells True
        
        'Hilight the new selection
        HilightSelection
        'Un-hilight the beginning of the selection
        HilightSelection lRow1, lCol1, lRow1, lCol1
        'Hilight the selection cell
        'HilightCell
        
        bRedraw = bOldRedraw
        If bRedraw Then picGrid.Refresh
        'picGrid.AutoRedraw = False
    Else
        lLeftCol = lNewLeftCol&
        RedrawAllCells True
    End If
    
    SetSizers
End Sub

Public Sub VChange()
Attribute VChange.VB_MemberFlags = "40"
    Dim iDirection As Integer
    Dim lpRect As RECT, lpOldRect As RECT
    Dim hRegion As Long
    Dim lMyColWidth As Long
    Dim lMyRowHeight As Long
    Dim x As Long, y As Long
    
    If bEditMode Then
        'Cells.Text(lCol, lRow) = txtEdit.Text
        bEditMode = False
        GetCellCoordinates lRow, lCol, x&, y&
        lMyColWidth = lColWidth(lCol)
        lMyRowHeight = lRowHeight(lRow)
        txtEdit.Visible = False
        txtEdit.ZOrder 1
        DrawCell lRow, lCol, x&, y&, lMyColWidth, lMyRowHeight
        DrawGridBorder
        HilightCell lRow, lCol
        RaiseEvent AfterEdit(CInt(lRow), CInt(lCol), Text)
    End If
    
    lNewTopRow& = scrVertical.Value
    iDirection = lTopRow - lNewTopRow&
    If Abs(iDirection) = 1 Then
        'picGrid.AutoRedraw = True
        bOldRedraw = bRedraw
        bRedraw = False
        
        'Un-hilight the old selection
        HilightSelection
        'Un-hilight the previous selected cell
        HilightSelection lRow1, lCol1, lRow1, lCol1
        'Un-hilight the border of the previous selected cell
        'HilightCell
        
        lOldTopRow& = lTopRow
        lTopRow = lNewTopRow&
        
        'Scroll the DC
        lpRect.Left = 1
        If bColHeader Then
            lpRect.Top = lRowHeight(0) + 2
        Else
            lpRect.Top = 1
        End If
        lpRect.Right = picGrid.ScaleWidth - 1
        If iDirection > 0 Then
            lMyRowHeight& = lRowHeight(lTopRow&) + 1
        Else
            lMyRowHeight& = lRowHeight(lOldTopRow&) + 1
        End If
        'If scrHorizontal.Visible Then
        '    lScrollHeight = scrHorizontal.Height
        'Else
            lScrollHeight = 0
        'End If
        
        lpRect.Bottom = picGrid.ScaleHeight - lScrollHeight - 1
        lRet = ScrollDC(picGrid.hDC, 0, lMyRowHeight& * iDirection, lpRect, lpRect, hRegion, lpOldRect)
        
        If iDirection > 0 Then
            DrawRow lTopRow&, lpRect.Top, True
        Else
            DrawBottomRows lTopRow&, lMyRowHeight&
        End If
        
        'DrawGrid                   kdq090498   replaced because background was not redrawing correctly
        RedrawAllCells False

        'Hilight the new selection
        HilightSelection
        'Un-hilight the beginning of the selection
        HilightSelection lRow1, lCol1, lRow1, lCol1
        'Hilight the selection cell
        'HilightCell
       
        bRedraw = bOldRedraw
        If bRedraw Then picGrid.Refresh
        'picGrid.AutoRedraw = False
    Else
        lTopRow = lNewTopRow&
        RedrawAllCells False
    End If
    
    SetSizers
End Sub

Public Sub DrawRow(lThisRow As Long, y As Long, bDrawHeader As Boolean)
Attribute DrawRow.VB_MemberFlags = "40"
    Dim lThisCol As Long, x As Long, lMyColWidth As Long, lMyRowHeight As Long
    Dim lScaleWidth As Long
    
    If bShowGrid Then
        bytGridLine = 1
    Else
        bytGridLine = 0
    End If
    
    lMyRowHeight = lRowHeight(lThisRow)
    If bRowHeader Then
        x& = 1
        lMyColWidth = lColWidth(0)
        'If bDrawHeader Then
            DrawCell lThisRow, 0, x&, y&, lMyColWidth, lMyRowHeight
        'End If
        x& = x& + lMyColWidth + bytGridLine
    Else
        x& = 1
    End If
    lScaleWidth = picGrid.ScaleWidth
    
    If lLeftCol > 1 Then
        bWidthOverflow = True
    Else
        bWidthOverflow = False          'kdq090198          added to make sure scrollbars turn on/off
    End If
    
    For lThisCol = lLeftCol To lCols
        lMyColWidth = lColWidth(lThisCol)
        DrawCell lThisRow, lThisCol, x&, y&, lMyColWidth, lMyRowHeight
        x& = x& + lMyColWidth + bytGridLine
        If x& > lScaleWidth - 1 Then
            bWidthOverflow = True
            If lLargeHChange = 0 Then
                lLargeHChange = lThisCol - lLeftCol             '- 1
                scrHorizontal.LargeChange = lLargeHChange
            End If
            Exit For
        End If
    Next
    lGridWidth = x& - 1
    If lGridWidth > lScaleWidth - 1 Then lGridWidth = lScaleWidth - 1
End Sub

Public Sub DrawCol(lThisCol As Long, x As Long, bDrawHeader)
Attribute DrawCol.VB_MemberFlags = "40"
    Dim lThisRow As Long, y As Long, lMyColWidth As Long, lMyRowHeight As Long
    Dim lScaleHeight As Long
    
    If bShowGrid Then
        bytGridLine = 1
    Else
        bytGridLine = 0
    End If
    
    lMyColWidth = lColWidth(lThisCol)
    If bColHeader Then
        y& = 1
        lMyRowHeight = lRowHeight(0)
        If bDrawHeader Then
            DrawCell 0, lThisCol, x&, y&, lMyColWidth, lMyRowHeight
        End If
        y& = y& + lMyRowHeight + bytGridLine
    Else
        y& = 1
    End If
    lScaleHeight& = picGrid.ScaleHeight
    
    If lTopRow > 1 Then
        bHeightOverflow = True
    Else
        bHeightOverflow = False          'kdq090198          added to make sure scrollbars turn on/off
    End If
    For lThisRow = lTopRow To lRows
        lMyRowHeight = lRowHeight(lThisRow)
        DrawCell lThisRow, lThisCol, x&, y&, lMyColWidth, lMyRowHeight
        y& = y& + lMyRowHeight + bytGridLine
        If y& > lScaleHeight Then
            bHeightOverflow = True
            'scrVertical.LargeChange = lThisRow - lTopRow - 2
            Exit For
        End If
    Next
    lGridHeight = y& - 1
    If lGridHeight > lScaleHeight - 1 Then lGridHeight = lScaleHeight - 1
End Sub

Private Sub DrawBottomRows(lThisTopRow As Long, lUpdateHeight As Long)
    Dim lScaleHeight As Long, lScaleWidth As Long
    
    lScaleHeight = picGrid.ScaleHeight
    lScaleWidth = picGrid.ScaleWidth
    
    If bShowGrid Then
        bytGridLine = 1
    Else
        bytGridLine = 0
    End If
    
    'If scrHorizontal.Visible Then
    '    lScrollHeight = scrHorizontal.Height
    'Else
        lScrollHeight = 0
    'End If
    
    If bColHeader Then
        y& = lRowHeight(0) + 1 + bytGridLine
    Else
        y& = 1
    End If
    For l& = lThisTopRow To lRows
        lMyRowHeight = lRowHeight(l&)
        If y& < lScaleHeight - lScrollHeight - lUpdateHeight - lMyRowHeight - 2 Then
            y& = y& + lMyRowHeight + bytGridLine
        Else
            For lRemainder& = l& To lRows
                DrawRow lRemainder&, y&, True
                y& = y& + lRowHeight(lRemainder&) + bytGridLine
                If l& = lRows& Or y& > lScaleHeight Then
                    Exit For
                End If
            Next
            Exit For
        End If
    Next
    lGridHeight& = y& - 1
    DrawBox 1, lGridHeight + 1, lScaleWidth, lScaleHeight - lGridHeight, COLOR_GREY
End Sub

'kdq090398 added this sub to draw grid border in black
Private Sub DrawGridBorder(Optional StartRow, Optional StartCol, Optional EndRow, Optional EndCol)
    Dim lpRect As RECT
        
    If IsMissing(StartRow) Then StartRow = lTopRow
    If IsMissing(StartCol) Then StartCol = lLeftCol
    If IsMissing(EndRow) Then EndRow = lRows
    If IsMissing(EndCol) Then EndCol = lCols
    If IsMissing(Inverted) Then Inverted = False
        
        GetCellCoordinates StartRow, StartCol, x1&, y1&
        GetCellCoordinates EndRow, EndCol, x2&, Y2&

        If iFixedStyle = 0 Then
            'draw top black line
            lpRect.Left = x1&
            lpRect.Top = y1&
            lpRect.Right = x2& + lColWidth(EndCol)
            lpRect.Bottom = y1&
            DrawLine lpRect, vbBlack
        End If

        'draw bottom black line
        lpRect.Left = x1&
        lpRect.Top = Y2& + lRowHeight(EndRow)
        lpRect.Right = x2& + lColWidth(EndCol)
        lpRect.Bottom = Y2& + lRowHeight(EndRow)
        DrawLine lpRect, vbBlack

        'draw left side black line
        If bRowHeader = False Then
            lpRect.Left = x1&
            lpRect.Top = y1&
            lpRect.Right = x1&
            lpRect.Bottom = Y2& + lRowHeight(EndRow)
            DrawLine lpRect, vbBlack
        End If

        'draw right side black line
        lpRect.Left = x2& + lColWidth(EndCol)
        lpRect.Top = y1&
        lpRect.Right = x2& + lColWidth(EndCol)
        lpRect.Bottom = Y2& + lRowHeight(EndRow)
        DrawLine lpRect, vbBlack

        If iFixedStyle = 0 Then
            DrawRect x1&, y1& - lRowHeight(StartRow) - 1, x2& + lColWidth(EndCol), y1&, vbBlack
        End If
End Sub

Private Sub DrawGrid(Optional StartRow, Optional StartCol, Optional EndRow, Optional EndCol, Optional Inverted)
    Dim lScaleWidth As Long, lScaleHeight As Long
    Dim lpRect As RECT
    
    If IsMissing(StartRow) Then StartRow = lTopRow
    If IsMissing(StartCol) Then StartCol = lLeftCol
    If IsMissing(EndRow) Then EndRow = lRows
    If IsMissing(EndCol) Then EndCol = lCols
    If IsMissing(Inverted) Then Inverted = False
    
    lScaleHeight = picGrid.ScaleHeight
    lScaleWidth = picGrid.ScaleWidth
    
    If bShowGrid Then
        If bGridSolid = False Then picGrid.DrawStyle = 2    'dotted
        
        GetCellCoordinates StartRow, StartCol, x1&, y1&
        x1& = x1&
        y1& = y1&
        GetCellCoordinates EndRow, EndCol, x2&, Y2&
        x2& = x2&
        Y2& = Y2&
        
        lpRect.Top = y1&
        lpRect.Bottom = Y2& + lRowHeight(EndRow)
        'X& = X1& + lColWidth(StartCol)
        If bRowHeader Then
            x& = lColWidth(0) + bytGridLine
        Else
            x& = 0
        End If
        For lThisCol = StartCol To EndCol
            x& = x& + lColWidth(lThisCol) + bytGridLine
            If x& > lScaleWidth Then Exit For
            lpRect.Left = x&
            lpRect.Right = x&
            DrawLine lpRect, lGridLineColor
        Next
        
        If bColHeader Then
            y& = lRowHeight(0) + bytGridLine
        Else
            y& = 0
        End If
        lpRect.Left = x1&
        lpRect.Right = x2& + lColWidth(EndCol)
        'Y& = Y1& + lRowHeight(StartRow)
        For lThisRow = StartRow To EndRow
            y& = y& + lRowHeight(lThisRow) + bytGridLine
            If y& > lScaleHeight Then Exit For
            lpRect.Top = y&
            lpRect.Bottom = y&
            DrawLine lpRect, lGridLineColor
        Next
        picGrid.DrawStyle = 0    'Solid
    
    End If
    
    'Draw the right, bottom and the grey box at the bottom right
    'DrawBottomRight
    DrawGridBorder StartRow, StartCol, EndRow, EndCol
    'Draw the blank grey box at the end of the scroll bars
    If (bWidthOverflow And bHeightOverflow) Or (scrHorizontal.Visible And scrVertical.Visible) Then DrawBox lScaleWidth - 20, lScaleHeight - 20, 20, 20, COLOR_GREY
End Sub

'Public Sub SetRowHeight(lThisRow&, lNewHeight&)
'    lRowHeight(lThisRow&) = lNewHeight&
'    RedrawAllCells True
'End Sub

Public Property Get Row() As Long
Attribute Row.VB_Description = "Sets/gets the current row"
Attribute Row.VB_MemberFlags = "400"
    Row = lRow
End Property

Public Property Let Row(lNewValue As Long)
    HilightCell lRow, lCol
    lRow = lNewValue
    HilightCell
End Property

Public Property Get Col() As Long
Attribute Col.VB_Description = "Gets/sets the current column number"
Attribute Col.VB_MemberFlags = "400"
    Col = lCol
End Property

Public Property Let Col(lNewValue As Long)
    HilightCell lRow, lCol

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -