Code: Select all
;requires DateAndTime and StringLibraryEx Libraries
;Download from [url]http://www.reelmediaproductions.com/pb[/url]
;will load current calendar date on start up then you may select any date to view
;a much nicer color calender with a better layout could be made and put in a function
;to draw on any window or whatever if you have time
;(replace the extra spaces at TextGadget(#TXT_WEEK_DAYS.... if they are lost at copy & paste )
If OpenWindow(0, 100, 100, 205, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget , "Multi-Year Calendar")
#CBO_MONTH=1:#CBO_YEAR=3:#TXT_STATIC_MONTH=4:#TXT_STATIC_YEAR=6:#CMD_UPDATE_CALENDER=7:
#TXT_CALENDAR=8:#TXT_WEEK_DAYS=9:#TXT_CALENDAR_MONTH=10:#FRA_CALENDAR=11:#FRA_MONTH=12
If CreateMenu(0)
MenuTitle("Help")
MenuItem( 1, "&About...")
EndIf
AttachMenu(0, WindowID())
InitGadget(18)
CreateGadgetList(WindowID())
ComboBoxGadget(#CBO_MONTH, 57, 5, 40, 2000)
ComboBoxGadget(#CBO_YEAR, 97, 5, 60, 200)
TextGadget(#TXT_STATIC_MONTH, 58, 30, 30, 20, "Month")
TextGadget(#TXT_STATIC_YEAR, 108, 30, 40, 15, "Year")
ButtonGadget(#CMD_UPDATE_CALENDER, 58, 48, 90, 25, "Update Calender")
TextGadget(#TXT_CALENDAR, 21, 125, 169, 80, "")
TextGadget(#TXT_WEEK_DAYS, 27, 108, 180, 15, "S M T W T F S")
TextGadget(#TXT_CALENDAR_MONTH, 58, 86, 90, 13, "")
Frame3DGadget(#FRA_CALENDAR, 5, 72, 190, 137, "", 0)
Frame3DGadget(#FRA_MONTH, 43, 77, 115, 25, "", 0)
GadgetToolTip(#CBO_MONTH, "Select Month")
GadgetToolTip(#CBO_YEAR, "Select Year")
GadgetToolTip(#CMD_UPDATE_CALENDER, "Create a new calendar")
For i=1 To 12
AddGadgetItem(1, -1, Str(i));load months
Next
For i=1800 To 2200
AddGadgetItem(3, -1, Str(i));load years
Next
Year$=Str(Year_());get current year
Month$=Str(Month_());get current month
SetGadgetText(#CBO_MONTH,Month$);set to current month
SetGadgetText(#CBO_YEAR,Year$);set to current year
Gosub CreateCalender ;create the calendar for current date
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventCloseWindow
Quit = 1
EndIf
If EventID =#PB_EventMenu
Select EventMenuID()
Case 1
j$=""
MessageRequester("About Multi-Year Calendar", "Created by Wayne Haas " + Chr(169)+"2001", 0)
EndSelect
EndIf
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 7
Gosub CreateCalender
EndSelect
EndIf
Until Quit = 1
EndIf
End
CreateCalender:
m$= GetGadgetText(#CBO_MONTH)
y$= GetGadgetText(#CBO_YEAR)
SetGadgetText(#TXT_CALENDAR,"")
Temp$=""
HowMany=HowManyDays_(Val(m$),Val(y$))
WeekDay=GetWeekDay_(Val(m$),1,Val(y$));set to the first day of the month (mon or tue...)
j=1
For i=1 To 7;set text for first week pad empty days
If i 7;wrap line if one week
Temp$=Temp$+Chr(10)
k=1;reset count
EndIf
j=j+1
Wend
SetGadgetText(#TXT_CALENDAR,Temp$);display calendar
Heading$=MonthName$(Val(GetGadgetText(#CBO_MONTH)),0)+Space$(2)+GetGadgetText(#CBO_YEAR)
SetGadgetText(#TXT_CALENDAR_MONTH,RSet$(Heading$,15));set month and year text for calendar
Return
Edited by - wayne1 on 24 December 2001 07:37:29