1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| Private Type Coordonnees
Col As Integer
Row As Integer
End Type
Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim Coord As Coordonnees
Coord = GetCoordonnees(x, y)
Debug.Print "(" & Coord.Row & "," & Coord.Col & ")"
End Sub
Private Function GetCoordonnees(x As Single, y As Single) As Coordonnees
Dim R As Integer
Dim SumR As Long
Dim C As Integer
Dim SumC As Long
On Error GoTo ErrCoord
C = MSFlexGrid1.LeftCol - MSFlexGrid1.FixedCols
Do While x > SumC
SumC = SumC + MSFlexGrid1.ColWidth(C)
If x <= SumC Then Exit Do
C = C + 1
Loop
R = MSFlexGrid1.TopRow - MSFlexGrid1.FixedRows
Do While y > SumR
SumR = SumR + MSFlexGrid1.RowHeight(R)
If y <= SumR Then Exit Do
R = R + 1
Loop
' *** Gestion des lignes et colones fixes *** '
If R < MSFlexGrid1.TopRow Then
GetCoordonnees.Row = MSFlexGrid1.FixedRows - MSFlexGrid1.TopRow + R
Else
GetCoordonnees.Row = R
End If
If C < MSFlexGrid1.LeftCol Then
GetCoordonnees.Col = MSFlexGrid1.FixedCols - MSFlexGrid1.LeftCol + C
Else
GetCoordonnees.Col = C
End If
Exit Function
ErrCoord:
GetCoordonnees.Row = -1
GetCoordonnees.Col = -1
End Function |
Partager