PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: jcmatt on February 26, 2009, 03:30:09 PM

Title: MonthCalendar control get and set date
Post by: jcmatt on February 26, 2009, 03:30:09 PM
Hi,

Anyone know how to get the currently selected date from a MonthCalendar control and how to set it to a new date?

Jim
Title: Re: MonthCalendar control get and set date
Post by: jcmatt on February 26, 2009, 05:39:17 PM
All is well.  I figured out how to do it.

Function FORM3_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     As Long,  _  ' index in Control Array
                                   hWndForm         As Dword, _  ' handle of Form
                                   hWndControl      As Dword, _  ' handle of Control
                                   idButtonControl  As Long   _  ' identifier of button
                                   ) As Long
   Local CalendarDate As SYSTEMTIME
   Local NewDate As String, StartDate As String
   
   SendMessage HWND_FORM3_MONTHCALENDAR1, %MCM_GETCURSEL, 0, VarPtr(CalendarDate)
   
   StartDate = Str$(CalendarDate.wMonth) + "/" + Str$(CalendarDate.wDay) + "/" + Str$(CalendarDate.wYear)

   NewDate = AddDaysToDate(StartDate, Val(FF_TextBox_GetText( HWND_FORM3_TEXT1)))
   
   CalendarDate.wYear  = Val(Parse$(NewDate, "/",3))
   CalendarDate.wMonth = Val(Parse$(NewDate, "/",1))
   CalendarDate.wDay   = Val(Parse$(NewDate, "/",2))
   
   SendMessage HWND_FORM3_MONTHCALENDAR1, %MCM_SETCURSEL, 0, VarPtr(CalendarDate) 'Set the date
End Function

Jim