Leban's MonthCalendar...

  • Thread starter Thread starter Dave Emmert
  • Start date Start date
D

Dave Emmert

I've recently been tinker with Leban's MonthCalender and wanted to add a
"Goto Today" to the menubar. I've figured how to add it to menubar, and can
set the control to the current date. My problem is that I don't want to
destroy the window, I want to see the calendar shift to the currentdate.
I'm sure that there is a way to do this.....

Would greatly appreciate any pointers.

Dave
 
The setting of certain properties requires that the Calendar control window
be destroyed and then recreated. OFTOMH I cannot remember whether setting
the current date requires this or not. You would have to read the docs on
MSDN for the MonthCalendar control.

Why can't you simply follow the existing update/create methods exposed by my
MonthCal class? In other words why do you care if the window is destroyed
then recreated?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
I guess that I'm not being too clear. What I am trying to do is to shift
the calendar's current view to the system date (along with a few other
dates), not necessary select that date. Think of it as page down event
rather than selecting a date. I could destroy and then recreate the class,
using a global variable to determine if the user really meant to select that
date or was merely browsing to it.

I've been developing a routine within modCalendar to use the KeysToMonthCal
event in a loop - first for months and then for days. It does the job
pretty well and thinking of adapting it with MCM_SETMONTHDELTA (mentioned on
MSDN and your website). Why loop, when I can set the MonthDelta and do it
once. I don't see where the MCM_SETMONTHDELTA is exposed in your class or
even defined as a value. Am I missing something?

Thanks,

Dave
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top