I use this code to select a date from a calendar :
- Code: Select all Expand view
STATIC FUNCTION MsgDatum(kDate)
LOCAL kDlg,kCursor,kSelect,kWork
LOCAL kRow,kCol ,kMonth ,kYear
LOCAL lMonths := {"January","February","March","April","May","June","July","August","September","October","November","December"}
LOCAL kPrompt := "Select a date"
DEFAULT(kDate,Date())
kLongDate := kDateToString(kDate)
kYear := VAL(STR(Year(kDate),4))
kMonth := Month(kDate)
kSelect := kDate
kWork := FT_FDAY(kDate)
DO WHILE DoW(kWork) > 1
kWork --
ENDDO
oFontSFB := GetStandardFont(1)
DEFINE DIALOG kDlg SIZE 250, 260 TITLE kPrompt FONT oFontSFB
@ 0.3, .75 COMBOBOX kMonth ITEMS lMonths SIZE 50,150 OF kDlg ;
ON CHANGE MoveKalender(kDlg, 1, kMonth)
@ 3.8, 62 BTNBMP PROMPT "-" SIZE 12,12 ACTION (MoveKalender(kDlg,3))
@ 3.8, 108 BTNBMP PROMPT "+" SIZE 12,12 ACTION (MoveKalender(kDlg,4))
@ 0.3, 9.5 GET kYear SIZE 31, 12 OF kDlg CENTERED WHEN .F.
ATail(kDlg:aControls):Cargo := "YEAR"
@ 1.5, 2 SAY PADC(kLongDate,28) OF kDlg COLOR CLR_BLUE
ATail(kDlg:aControls):Cargo := "DATE"
@ 2.4, 1.2 SAY "Sun Mon Tue Wed Thu Fri Sat" COLOR CLR_HRED
FOR kRow = 2 TO 7
FOR kCol = 1 TO 7
@ (kRow*13)+22,(kCol*16)-6 BTNBMP PROMPT STR(DAY(kWork),2) SIZE 11.8,11.8 NOBORDER ACTION(kDlg:Cargo := ::Cargo,kDlg:End(IDOK))
ATail(kDlg:aControls):Cargo := kWork
ATail(kDlg:aControls):nClrText := IF(kWork=Date(),CLR_HRED,IF(kWork=kDate,CLR_BLUE,IF(MONTH(kWork)=kMonth,IF(kCol=1 .OR. kCol=7,CLR_HBLUE,CLR_BLACK),CLR_GRAY)))
IF ATail(kDlg:aControls):Cargo = kDate
ATail(kDlg:aControls):lPressed := .T.
ATail(kDlg:aControls):cToolTip := "Selected"
ELSEIF ATail(kDlg:aControls):Cargo = Date()
ATail(kDlg:aControls):cToolTip := "Today"
ELSE
ATail(kDlg:aControls):cToolTip := DToC(ATail(kDlg:aControls):Cargo)
ENDIF
kWork++
NEXT
NEXT
kDlg:Cargo := kDate
kDlg:lHelpIcon := PAR->HELPICON
IF !US->U3DLOOK ; kDlg:nStyle := nOr(kDlg:nStyle,4) ; ENDIF
IF PAR->RESIZE16
ACTIVATE DIALOG kDlg CENTERED
ELSE
ACTIVATE DIALOG kDlg RESIZE16 CENTERED
ENDIF
oFontSFB := GetStandardFont(1)
kSelect := kDlg:Cargo
RETURN(IF(kDlg:nResult=IDOK,kSelect,kDate))
******************************************************************************
STATIC FUNCTION MoveKalender(kDlg,nMode,nVar)
LOCAL kSelect := kDlg:Cargo
LOCAL n
LOCAL nFirstButton := 0
LOCAL nLastButton := 0
LOCAL nDate := 0
LOCAL nSkip := 0
LOCAL nPDate := 0
LOCAL nPYear := 0
LOCAL nDay, kMonth, kYear
LOCAL kWork
LOCAL nDays := 0
LOCAL MaxDay := {31,28,31,30,31,30,31,31,30,31,30,30}
FOR n = 1 TO LEN(kDlg:aControls)
IF kDlg:aControls[n]:ClassName() = "TBTNBMP"
nFirstButton := IF(nFirstButton=0,IF(nSkip<2,0,n),nFirstButton)
nLastButton := n
nSkip++
kDlg:aControls[n]:lPressed := .F.
ENDIF
IF VALTYPE(kDlg:aControls[n]:Cargo) = "C"
IF kDlg:aControls[n]:Cargo = "DATE"
nPDate := n
ENDIF
IF kDlg:aControls[n]:Cargo = "YEAR"
nPYear := n
ENDIF
ENDIF
NEXT
nDay := Day(kSelect)
kMonth := Month(kSelect)
kYear := Year(kSelect)
DO CASE
CASE nMode = 1
kMonth := nVar
CASE nMode = 3
kYear--
CASE nMode = 4
kYear++
ENDCASE
IF (kYear/4) - (INT(kYear/4)) = 0 ; MaxDay[2] := 29 ; ENDIF
IF nDay > MaxDay[kMonth] ; nDay := MaxDay[kMonth] ; ENDIF
kSelect := CTOD(PADL(nDay,2) + "/" + PADL(kMonth,2) + "/" + PADL(kYear,4))
kLongDate := kDateToString(kSelect)
kDlg:aControls[nPDate]:cMsg := kLongDate
kDlg:aControls[nPYear]:VarPut(VAL(STR(kYear,4)))
kWork := FT_FDAY(kSelect)
DO WHILE DOW(kWork) > 1
kWork --
ENDDO
FOR n = nFirstButton TO nLastButton
kDlg:aControls[n]:SetText(STR(DAY(kWork),2))
kDlg:aControls[n]:Cargo := kWork
kDlg:aControls[n]:nClrText := IF(kWork=Date(),CLR_HRED,IF(kWork=kSelect,CLR_BLUE,IF(MONTH(kWork)=kMonth,IF(DOW(kWork)=1 .OR. DOW(kWork)=7,CLR_HBLUE,CLR_BLACK),CLR_GRAY)))
kDlg:aControls[n]:cToolTip := DTOC(kWork)
IF kWork = kSelect
kDlg:aControls[n]:lPressed := .T.
kDlg:aControls[n]:cToolTip := "Selected"
ENDIF
kWork++
NEXT
FOR n = 1 TO Len(kDlg:aControls)
kDlg:aControls[n]:Refresh()
NEXT
kDlg:Cargo := kSelect
RETURN(NIL)
******************************************************************************
STATIC FUNCTION kDateToString(kDate)
LOCAL dMonths := {"January","February","March","April","May","June","July","August","September","October","November","December"}
LOCAL dDays := {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}
RETURN(dDays[DOW(kDate)]+", "+STR(DAY(kDate),2)+" "+dMonths[MONTH(kDate)]+" "+STR(YEAR(kDate),4))
In FWH 8.10 and previous, this results into this :
But in FWH 8.11, this is the result :
Anyone any idea what is wrong ?
Thanks.