Private Sub DrawingDate(ByVal CurrentDate As Date)
Dim strText As String, lngBack As Long, lngFore As Long, fFont As New StdFont, intAlign As MSHierarchicalFlexGridLib.AlignmentSettings
With MSFCAL
lngBack = .CellBackColor: lngFore = .CellForeColor
fFont.Name = .CellFontName: fFont.Size = .CellFontSize
fFont.Bold = .CellFontBold: fFont.Italic = .CellFontItalic
fFont.Strikethrough = .CellFontStrikeThrough: fFont.Underline = .CellFontUnderline
intAlign = .CellAlignment: strText = Str(Day(CurrentDate))
RaiseEvent DrawDate(CurrentDate, strText, lngBack, lngFore, fFont, intAlign)
.CellBackColor = lngBack: .CellForeColor = lngFore
.CellFontName = fFont.Name: .CellFontSize = fFont.Size
.CellFontBold = fFont.Bold: .CellFontItalic = fFont.Italic
.CellFontStrikeThrough = fFont.Strikethrough: .CellFontUnderline = fFont.Underline
.CellAlignment = intAlign: .Text = strText
End With
End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionc'était du VB6 puisque je l'avais posté en VB6.
Option Explicit
Private p_TCalProp As TCalProperties
Private p_TDateCoord As TDateCoord, p_TZeroCellCoord As CellCoord
Private p_intDayValue As Integer
Private p_blnCheckDate As Boolean, p_blnInitialized As Boolean
'********************************************************************************************************************************
'* *
'* EVENEMENTS du Contrôle: Calendar *
'* *
'********************************************************************************************************************************
Public Event Click()
Public Event DrawDate(ByVal xDateValue As Date, ByRef CellText As String, ByRef xBackColor As Long, ByRef xForeColor As Long, ByRef xFont As StdFont, ByRef xAlignment As MSHierarchicalFlexGridLib.AlignmentSettings)
Public Event DblClick()
Public Event KeyDown(ByRef KeyCode As Integer, ByRef Shift As Integer)
Public Event KeyPress(ByRef KeyAscii As Integer)
Public Event MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Public Event MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Public Event MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Public Sub DrawCalendar()
Dim bytDaysCount As Byte, dCaldate As Date, X As Integer, Y As Integer
bytDaysCount = BH_DaysInMonth(DateValue)
With MSFCAL
.Clear
.FixedRows = Abs(ShowWeekDay): .FixedCols = Abs(ShowWeekNumber)
.BackColorFixed = BackColor: .ForeColorFixed = TrailForeColor
.ColAlignmentFixed = flexAlignCenterCenter: .GridColor = ForeColor
.GridColorFixed = WeekLinesColor
dCaldate = CDate("01/" & MonthValue & "/" & YearValue): .Cols = IIf(ShowWeekNumber, 8, 7)
.Rows = IIf(((BH_DaysInMonth(, MonthValue) + (Weekday(dCaldate, vbMonday) - 1)) > 35), 6, 5) + .FixedRows
If ShowTrailingDates Then dCaldate = DateAdd("d", -(Weekday(dCaldate, vbMonday) - 1), dCaldate)
If ShowWeekDay Then
For Y = IIf(ShowWeekNumber, 1, 0) To .Cols - 1
.Row = 0: .Col = Y:
.Text = BH_DayOfWeek(, CInt(Y + IIf(ShowWeekNumber, 0, 1)), True, ccProperCase)
.CellBackColor = WeekBackColor: .CellForeColor = WeekForeColor
Next
End If
If ShowWeekNumber Then
For X = IIf(ShowWeekDay, 1, 0) To .Rows - 1
.Row = X: .Col = 0
.Text = DatePart("ww", DateAdd("d", (7 * (X - IIf(ShowWeekDay, 1, 0))), dCaldate), vbMonday, vbFirstFourDays)
.CellBackColor = WeekBackColor: .CellForeColor = WeekForeColor
Next
.ColWidth(.Col) = (Width / .Cols)
End If
If ShowWeekDay And ShowWeekNumber Then
.Row = 0: .Col = 0
.CellBackColor = WeekBackColor: .CellForeColor = WeekForeColor
End If
.Row = IIf(ShowWeekDay, 1, 0): .Col = 0
p_TDateCoord.DateValue = p_TZeroCellCoord
For dCaldate = dCaldate To DateAdd("d", (((.Rows - .FixedRows) * 7) - 1), dCaldate)
If Not ShowTrailingDates And Month(dCaldate) <> MonthValue Then Exit For
.Row = IIf(.Col + IIf(ShowWeekNumber, 0, 1) = 7, .Row + 1, .Row)
.Col = (Weekday(dCaldate, vbMonday) - IIf(ShowWeekNumber, 0, 1))
.Text = Day(dCaldate)
If Month(dCaldate) = MonthValue Then
.CellBackColor = BackColor: .CellForeColor = ForeColor
Else
.CellBackColor = BackColor: .CellForeColor = TrailForeColor
End If
If dCaldate = CDate(BH_DatePart("DD", DateValue)) Then
p_TDateCoord.DateValue.Row = .Row: p_TDateCoord.DateValue.Col = .Col
End If
.ColWidth(.Col) = (.Width / .Cols): .CellAlignment = DaysAlignment
Call DrawingDate(dCaldate)
Next
End With
If ShowDateValue Then
MSFCAL.Row = p_TDateCoord.DateValue.Row: MSFCAL.Col = p_TDateCoord.DateValue.Col
MSFCAL.CellBackColor = DateBackColor: MSFCAL.CellForeColor = DateForeColor
MSFCAL.CellFontName = DateFont.Name: MSFCAL.CellFontSize = DateFont.Size
MSFCAL.CellFontBold = DateFont.Bold: MSFCAL.CellFontItalic = DateFont.Italic
MSFCAL.CellFontStrikeThrough = DateFont.Strikethrough: MSFCAL.CellFontUnderline = DateFont.Underline
MSFCAL.CellTextStyle = DateStyle: MSFCAL.CellAlignment = DateAlignment
MSFCAL.Text = Day(DateValue)
End If
MSFCAL.RowHeightMin = (MSFCAL.Height / MSFCAL.Rows)
End Sub