#include once "window9.bi"

Type SYSTEMDATEANDTIME_
  As Short Year_
  As Short Month_
  As Short Weekday_
  As Short Day_
  As Short Hour_
  As Short minute_
  As Short second_
  As Short msec_
End Type
Dim shared sTime As SYSTEMDATEANDTIME_

Function GetStateCalendar Alias "GetStateCalendar"(ByVal gadget As Integer,ByVal flag As Byte=5) As Integer Export
  SendMessage(GadgetID(gadget), 4097,0 ,Cast(LPARAM,@sTime))
  If flag=1 Then
    Return sTime.Year_
  ElseIf flag=2 Then
    Return sTime.Month_
  elseIf flag=3 Then
    Return sTime.Weekday_
  elseIf flag=4 Then
    Return sTime.Day_
  elseIf flag=5 Then
    Return Val(sTime.Year_ & sTime.Month_ &  sTime.Day_)
  End If
End Function
