Evènement ne se déclenche pas !

Calade Messages postés 1207 Date d'inscription dimanche 20 avril 2003 Statut Membre Dernière intervention 4 juin 2016 - 8 oct. 2014 à 10:12
Calade Messages postés 1207 Date d'inscription dimanche 20 avril 2003 Statut Membre Dernière intervention 4 juin 2016 - 21 oct. 2014 à 09:18
Bonjour,

Je suis en train de développer un contrôle calendrier à l'aide d'un MSHFlexgrid.
Pour permettre à l'utilisateur de modifier l'apparence d'une date précise (par exemple le backColor), j'utilise un évènement prenant comme paramètres (et par référence) certaines caractéristiques de la cellule. Or cet évènement ne se déclenche pas !

La déclaration de mon évènement:
Public Event DrawDate(ByVal xDateValue As Date, ByRef xBackColor As Long, ByRef xForeColor As Long, ByRef xFont As StdFont, ByRef xAlignment As MSHierarchicalFlexGridLib.AlignmentSettings)


Le code censé déclencher l'évènement en question:

Private Sub DrawingDate(ByVal CurrentDate As Date)
Dim lngBack As Long, lngFore As Long, fFont As StdFont, intAlign As MSHierarchicalFlexGridLib.AlignmentSettings

lngBack = BackColor: lngFore = ForeColor
Set fFont = Font: intAlign = DaysAlignment
RaiseEvent DrawDate(CurrentDate, lngBack, lngFore, fFont, intAlign)
With MSFCAL
.CellBackColor = lngBack: .CellForeColor = lngFore
.CellFontName = fFont.Name: .CellFontSize = fFont.Size
.CellFontBold = fFont.Bold: .CellFontItalic = fFont.Italic
.CellFontStrikeThrough = fFont.Strikethrough: .CellFontUnderline = fFont.Underline
.CellAlignment = intAlign
End With
End Sub


Si quelqu'un a une idée !
Je précise que ce pourrait être lié à ce code, car si je remplace l'évènement DrawDate, par (par exemple) l'évènement Click qui fonctionne par ailleurs, il n'est pas non plus déclenché ici !

Voilà et merci d'avance pour vos réponses.

10 réponses

Calade Messages postés 1207 Date d'inscription dimanche 20 avril 2003 Statut Membre Dernière intervention 4 juin 2016 10
8 oct. 2014 à 10:45
Bonjour NHenry et merci de ta réponse.

C'est même la première chose que j'ai faîte, j'ai placé un point d'arrêt sur le RaiseEvent de la procédure DrawingDate et il passe dessus comme si l'évènement n'était pas géré dans le code appelant.

Or il l'est et a été écrit avec l'intellisense pour être sur qu'il soit bien reconnu. Voici le code de test dans l'appelant:

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

1
Calade Messages postés 1207 Date d'inscription dimanche 20 avril 2003 Statut Membre Dernière intervention 4 juin 2016 10
8 oct. 2014 à 11:15
à jordane45,

OK alors autant pour moi, je n'avais pas fait attention.
1
NHenry Messages postés 15070 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 9 juin 2023 158
8 oct. 2014 à 10:21
As-tu essayer de mettre un point d'arrêt sur ton RaiseEvent pour voir si le code est réellement appelé ?

Comment gères-tu l'événement ?
0
Calade Messages postés 1207 Date d'inscription dimanche 20 avril 2003 Statut Membre Dernière intervention 4 juin 2016 10
8 oct. 2014 à 10:35
Un modérateur vient de déplacer mon message dans le forum .NET.
Effectivement, je ne précisais pas que c'était du VB6 puisque je l'avais posté en VB6.
Mon code est du pur VB6.

Si un modérateur pouvait remettre le message dans le bon forum, merci.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
NHenry Messages postés 15070 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 9 juin 2023 158
8 oct. 2014 à 10:40
Corrigé
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 219
8 oct. 2014 à 11:03
Bonjour, Calade,
Impossible de t' aider sur la base du sedul code que tu montres.
- Où et comment (code) as-tu défini l'évènement DrawDate ?
- par quelle procédure évènementielle appelles-tu la sub montrée ?
0
jordane45 Messages postés 37547 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 9 juin 2023 341
8 oct. 2014 à 11:13
c'était du VB6 puisque je l'avais posté en VB6.

Heu.. sauf que tu avais posté dans BASIC (la racine du forum).. et non dans VB6 ....
0
Calade Messages postés 1207 Date d'inscription dimanche 20 avril 2003 Statut Membre Dernière intervention 4 juin 2016 10
8 oct. 2014 à 11:13
Bonjour ucfoutu et merci de ta réponse,

l'évènement a été défini au tout début de mon code comme indiqué dans mon 1er post:

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)


le revoici avec un code un peu plus large.

Quant à l'appel de la sub, il est dans le code ci-dessous. Celui-ci dessine et remplit un calendrier selon un mois donné. Le sub et l'évènement posant problème ne sont là que pour ajouter une flexibilité de plus pour certaines dates (vacances, fériés, etc...).

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
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 219
8 oct. 2014 à 11:21
Ta réponse ne répond pas à cette question, que je répète donc :
par quelle procédure évènementielle appelles-tu la sub montrée ?
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 219
Modifié par ucfoutu le 8/10/2014 à 11:30
Je ne n'utilise par ailleurs pas ton contrôle calendar
Drawdate en est-t-il un évènement prédéfini par son auteur ?
0
Calade Messages postés 1207 Date d'inscription dimanche 20 avril 2003 Statut Membre Dernière intervention 4 juin 2016 10
21 oct. 2014 à 09:18
Bonjour ucfoutu,

Désolé mais j'avais complètement zappé que tu avais répondu à mon dernier post.

Pour y répondre, il est normal que tu n'utilises pas ce contrôle calendrier puisque c'est je suis en train de le développer.
Quant à la sub c'est un évènement déclenché par ce composant par un RaiseEvent et destiné à "customiser" certaines dates comme les jours fériés.

Ceci dit, ne cherche plus. Cela provenait que dans les propriétés du projet il y avait "pas de Compatibilité" au lieu de "Compatibilité des Projets". D'ailleurs si tu pouvais m'expliquer le fonctionnement de cette fameuse compatibilité car j'avoue que là dessus l'aide en ligne est un peu nébuleuse.

Merci d'avance.
0