Okay,
I've been experimenting further and MCM_SETMONTHDELTA does not affect the
WM_KEYDOWN, WM_KEYUP events. It only plays a role when the user press the
forward or backwards buttons. This is the code that I have come up with:
Private Sub SetScreen(ByVal lngWparam As Long, ByVal hWnd As Long, ByVal
lparam As Long)
Dim dDate As Date, dSelected As Date, lngShift As Long, i As Integer
dDate = Date
If SelChangeDateStart = 0 Then
dSelected = mc.StartSelectedDate
Else
dSelected = SelChangeDateStart
End If
lngShift = DateDiff("m", dSelected, dDate)
If lngShift <> 0 Then
For i = 1 To Abs(lngShift)
If lngShift > 0 Then
KeysToMonthCal hWnd, WM_KEYDOWN, vbKeyPageDown, lparam
ElseIf lngShift < 0 Then
KeysToMonthCal hWnd, WM_KEYDOWN, vbKeyPageUp, lparam
End If
Next i
End If
dSelected = DateAdd("m", lngShift, dSelected)
lngShift = DateDiff("ww", dSelected, dDate)
If lngShift <> 0 Then
For i = 1 To Abs(lngShift)
If lngShift > 0 Then
KeysToMonthCal hWnd, WM_KEYDOWN, VK_DOWN, lparam
ElseIf lngShift < 0 Then
KeysToMonthCal hWnd, WM_KEYDOWN, VK_UP, lparam
End If
Next i
End If
dSelected = DateAdd("ww", lngShift, dSelected)
lngShift = DateDiff("d", dSelected, dDate)
If lngShift <> 0 Then
For i = 1 To Abs(lngShift)
If lngShift > 0 Then
KeysToMonthCal hWnd, WM_KEYDOWN, VK_RIGHT, lparam
ElseIf lngShift < 0 Then
KeysToMonthCal hWnd, WM_KEYDOWN, VK_LEFT, lparam
End If
Next i
End If
End Sub
I could probably condense the code and use a loop with a couple of arrays.
I'm planning to use lngWparam to pass the selected date to dDate: Today,
Beginning Fiscal Year, Ending Fiscal Year, Beginning Calendar Year, Ending
Calendar Year, Forward One Year, Back One Year, etc. Any thoughts on this?
Dave