program MONCAL,1.0(106) ! test month calendar !----------------------------------------------------------- !EDIT HISTORY ![100] August 23, 2006 03:26 PM Edited by joaquin ! Created ![102] August 28, 2006 10:20 AM Edited by joaquin ! Display row/col indicators to help judge the display ! size of the calendar ![103] October 11, 2007 10:46 AM Edited by joaquin ! Add options for window type, caption, sysmenu ![104] July 10, 2008 10:35 AM Edited by joaquin ! Use INFLD date TYPE codes to enforce date format; ! query date from calendar on ? ![105] October 25, 2008 09:36 AM Edited by jacques ! Add F3/F4 to test disabling/enabling calendar ![106] April 06, 2011 10:03 PM Edited by jack ! Support new option to specify # of calendars (1212+) !----------------------------------------------------------- significance 11 MAP1 MISC MAP2 CALID,B,2 MAP2 DLGID,B,2 MAP2 STATUS,F MAP2 EXITCODE,F MAP2 ENTRY,S,32 MAP2 TIMER,F MAP2 CMDFLG,F MAP2 OP,F MAP2 INXCTL,F MAP2 DLG$,S,1 MAP2 SR,F MAP2 SC,F MAP2 ER,F MAP2 EC,F MAP2 DWSTYLE,B,4 MAP2 DAYSTATES$,S,1 MAP2 DSTARY$,S,32 ! string of 0's and 1's for day states MAP2 M,F MAP2 R,F MAP2 C,F MAP2 WTYPE,B,1 MAP2 CAPTION$,S,1 MAP2 SYSMENU$,S,1 MAP2 CTYPE2,B,4 ! [106] MAP2 CALCNT,B,1 ! [106] ++include ashinc:ashell.def ++include sosfunc:fnminasver.bsi ! [106] Fn'MinAshVer() ? tab(-1,0);"Test Month Calendar" ? "Note: hit ENTER to all questions for default example" ! [106] DLG$="N" input "Use dialog? [N]",DLG$ DLG$ = ucs(DLG$) ! [106] if 5.1.1211.1+, allow option of specifying # of calendars ! [106] in place of ending coordinates.. if Fn'MinAshVer(5,1,1211,1) >= 0 then input "# of calendars desired [1] : ",CALCNT CALCNT = CALCNT max 1 else CALCNT = 1 endif ! [106] since it is difficult to calculate the size required for ! [106] multiple calendars, with 1211.1+ you can specify the number ! [106] down and across in ER,EC (flagged with MBF2_PIXSIZE) if CALCNT > 1 then ! [106]- input "Upper left coordinate (sr,sc): ",SR,SC if SR+SC=0 then ? " Using default upper left 1,100 (top right)" SR = 1 SC = 100 endif input "# calendars (# down, # across): ",ER,EC if ER+EC=0 then ? " Using default 1 x";CALCNT ER = 1 ! 1 row of calendars EC = CALCNT ! n calendars wide endif CTYPE2 = MBF2_PIXSIZE else ! -[106] input "Calendar coordinates (sr,sc,er,ec): ",SR,SC,ER,EC endif if SR+SC+ER+EC=0 then ? "Using default coordinates: 1,100 - 1,100 (top right)" SR = 1 SC = 100 ER = 1 EC = 100 endif input "Optional range (CCYYMMDD-CCYYMMDD): ",ENTRY if CALCNT = 0 then ! [106] input "Use day states? [N] ",DAYSTATES$ else DAYSTATES$ = "N" ! [106] ? " (day states not compatible with multiple calendars)" ! [106] endif DAYSTATES$ = ucs(DAYSTATES$) WTYPE=0 ! normal child ! Note: notifications don't work with overlapped version input "Control type 0=normal(child), 1=popup, 2=overlapped [0]: ",WTYPE if WTYPE=0 then CAPTION$="N" SYSMENU$="N" else CAPTION$="Y" SYSMENU$="Y" endif ! [103]- ? "Display caption (title bar)? [";CAPTION$;"] "; input "",CAPTION$ ? "Display sysmenu (X button)? [";SYSMENU$;"] "; input "",SYSMENU$ if DLG$="Y" then xcall AUI,AUI_CONTROL,CTLOP_ADD,DLGID,"Title",MBST_ENABLE, & MBF_KBD+MBF_DIALOG+MBF_ALTPOS, & "","",STATUS,3,35,20,79 xcall MIAMEX,MX_AUTOPARENT,DLGID endif ! set styles DWSTYLE = 0 if ucs(CAPTION$)="Y" then DWSTYLE = DWSTYLE or WS_CAPTION if ucs(SYSMENU$)="Y" then DWSTYLE = DWSTYLE or WS_SYSMENU if WTYPE=1 then DWSTYLE = DWSTYLE or (WS_POPUP + WS_VISIBLE) if WTYPE=2 then DWSTYLE = DWSTYLE or WS_VISIBLE ! (removes WS_CHILD) if DAYSTATES$ = "Y" then & DWSTYLE = DWSTYLE or MCS_DAYSTATE ! support day states ! these options can be turned on/off manually ! DWSTYLE = DWSTYLE or MCS_NOTODAY ! don't display "today" date ! DWSTYLE = DWSTYLE or MCS_NOTODAYCIRCLE ! don't circle today's date ! DWSTYLE = DWSTYLE or MCS_WEEKNUMBERS ! display week numbers ! DWSTYLE = DWSTYLE or MCS_NOTRAILINGDATES ! [106] (vista+) don't show ! days from prv/nxt month ! DWSTYLE = DWSTYLE or MCS_SHORTDAYSOFWEEK ! [106] (vista+) short day ! names displayed in hdr ! Note: this one conflicts with DAYSTATES option... ! DWSTYLE = DWSTYLE or MCS_NOSELCHANGEONNAV! [106] (vista+) don't chg ! sel on nxt/prv month ! first, put the month calendar up xcall AUI,AUI_CONTROL,CTLOP_ADD,CALID,"Title",MBST_ENABLE,MBF_KBD, & "VK_xF111","",STATUS,SR,SC,ER,EC,-2,-2,0,0,"", & "Click a date to select",DLGID, & "ASHMONTHCAL",DWSTYLE,WS_EX_TOPMOST,CTYPE2 ! [106] add CTYPE2 ! [101] put up some indicators to check the size of the calendar if DLG$ = "Y" then if SC=1 then C = 43 else C = 1 ! use one edge or the other for R = 1 to 8 xcall AUI,AUI_CONTROL,CTLOP_ADD,0,str(R),MBST_ENABLE, & MBF_STATIC,"","",NUL_CSTATUS,R,C,R,C next R for C = 1 to 44 xcall AUI,AUI_CONTROL,CTLOP_ADD,0,"|",MBST_ENABLE, & MBF_STATIC,"","",NUL_CSTATUS,9,C,9,C next C endif ! set the range if they specified one xcall AUI,AUI_CONTROL,CTLOP_CHG,CALID,ENTRY,MBST_TEXTONLY, & 0,"","",STATUS if DAYSTATES$ = "Y" then ! make the 1st and 15th bold DSTARY$ = "1000000000000010000000000000000" ! (must be 31 digits) xcall AUI,AUI_CONTROL,CTLOP_CHG,CALID,DSTARY$,MBST_TEXTONLY, & 0,"","",STATUS endif LOOP: tprint tab(14,1);"Click calendar or enter date (F1=qry,F3/F4=dis/enable,ESC=exit): "; ! [104] Change |G#1] to |gD>1] xcall INFLD,14,50,8,0,"|gD>1]",ENTRY,INXCTL,1+DLGID,OP,EXITCODE,TIMER, & CMDFLG,-1,-1,-1 trace.print "$# $T EXITCODE = "+EXITCODE tprint tab(15,5);"EXITCODE = " tprint tab(15,20);EXITCODE tprint tab(16,5);tab(-1,10); ! [104] if EXITCODE = -3 then ! [105] disable xcall AUI,AUI_CONTROL,CTLOP_CHG,CALID,"",MBST_DISABLE xcall MSGBOX,"Calendar disabled (hit F4 to enable)", "MONCAL", & MBTN_OK,MBICON_ICON,MBMISC_TASKMODAL goto LOOP endif if EXITCODE = -4 then ! [105] enable xcall AUI,AUI_CONTROL,CTLOP_CHG,CALID,"",MBST_ENABLE xcall MSGBOX,"Calendar disabled (hit F3 to disable)", "MONCAL", & MBTN_OK,MBICON_ICON,MBMISC_TASKMODAL goto LOOP endif if EXITCODE = -5 then ! [105] test whether TAB(-1,10) deletes it ? tab(-1,1);tab(-1,10); goto LOOP endif if EXITCODE = -111 then ! date clicked in calendar trace.print "Received signal from calendar; querying... " ! use same opcode as for querying checkboxes xcall AUI,AUI_CONTROL,CTLOP_QRYCB,CALID,"",0,0,"","",STATUS ENTRY = STATUS using "########" ! CCYYMMDD trace.print " date = "+ENTRY M = val(ENTRY[5,6]) ! month # ! when we make a change to the date, if the month changed ! and we are using the DAYSTATE mode, then we should reset ! the states for the new current month. Here we just hard ! code them again to the 1st and 15th plus the day matching ! the month number if DAYSTATES$ = "Y" then ! make the 1st and 15th bold DSTARY$ = "1000000000000010000000000000000" ! (must be 31 digits) ! and the month number day if M > 0 then DSTARY$[M,M] = "1" xcall AUI,AUI_CONTROL,CTLOP_CHG,CALID,DSTARY$,MBST_TEXTONLY endif OP = 1 goto LOOP endif if EXITCODE = 1 then goto ENDIT if EXITCODE = 0 and val(ENTRY)>0 then ! normal keyboard entry ! try to update the date xcall AUI,AUI_CONTROL,CTLOP_CHG,CALID,ENTRY,MBST_TEXTONLY OP = 1 goto LOOP endif ! [104] on F1, query calendar if EXITCODE = -1 then xcall AUI, AUI_CONTROL, CTLOP_QRYCB, CALID, NUL_CTEXT$, NUL_CSTATE, & NUL_CTYPE, NUL_CMD$, NUL_FUNC$, STATUS tprint tab(13,5);tab(-1,10);"Calendar query returns STATUS=";STATUS ! if return STATUS = 0, try again (bug workaround) if STATUS = 0 then xcall AUI, AUI_CONTROL, CTLOP_QRYCB, CALID, NUL_CTEXT$, NUL_CSTATE, & NUL_CTYPE, NUL_CMD$, NUL_FUNC$, STATUS tprint tab(14,5);tab(-1,10);"Calendar query returns STATUS=";STATUS endif OP = 1 goto LOOP endif ENDIT: ! delete the calendar xcall AUI,AUI_CONTROL,CTLOP_DEL,CALID ! delete the dialog if DLGID then xcall AUI,AUI_CONTROL,CTLOP_DEL,DLGID endif end