**************************************************
PUBLIC goFDOne, goFDTwo, goFDatePicker
goFDOne = NEWOBJECT("frmFDOne")
goFDOne.Visible = .T.
goFDOne.Show
goFDTwo = NEWOBJECT("frmFDTwo")
goFDTwo .Visible = .T.
goFDTwo .Show
goFDatePicker = NEWOBJECT("frmFDatePicker")
Read Events
Close all
Clear All
RETURN
**************************************************
DEFINE CLASS frmFDOne AS Form
Caption = "Dates"
ShowTips = .T.
Top = 24
Left = 24
Height = 120
Width = 270
BorderStyle = 2
DataSession = 2
goObject = .NULL.
giTop = 150
giLeft = 150
ADD OBJECT lblRClick as Label WITH ;
Top = 12, Left = 12, AutoSize = .T., Caption = "Rightclick on any textbox to call the datepicker"
ADD OBJECT lblD1 as Label WITH ;
Top = 36, ;
Left = 12, ;
Caption = "Date 1"
ADD OBJECT lblD2 as Label WITH ;
Top = 72, ;
Left = 12, ;
Caption = "Date 2"
ADD OBJECT lblDay1 as Label WITH ;
Top = 36, Left = 174, Caption = ""
ADD OBJECT lblDay2 as Label WITH ;
Top = 72, Left = 174, Caption = ""
ADD OBJECT txtD1 as TextBox WITH ;
Top = 36, ;
Left = 60, ;
ReadOnly = .T., ;
ControlSource = "csrDates.dDateOne"
PROCEDURE txtD1.Refresh()
ThisForm.lblDay1.Caption = CDOW(This.Value)
ENDPROC
PROCEDURE txtD1.RightClick()
ThisForm.goObject = This
goFDatePicker.Top = ThisForm.giTop
goFDatePicker.Left = ThisForm.giLeft
goFDatePicker.goCallingForm = goFDOne
IF EMPTY(This.Value)
WITH goFDatePicker
.spnYear.Value = YEAR(DATE())
.spnMonth.Value = MONTH(DATE())
.spnDay.Value = DAY(DATE())
ENDWITH
ELSE
WITH goFDatePicker
.spnYear.Value = YEAR(This.Value)
.spnMonth.Value = MONTH(This.Value)
.spnDay.Value = DAY(This.Value)
ENDWITH
ENDIF
goFDatePicker.Show(1)
ENDPROC
ADD OBJECT txtD2 as TextBox WITH ;
Top = 72, ;
Left = 60, ;
ReadOnly = .T., ;
ControlSource = "csrDates.dDateTwo"
PROCEDURE txtD2.Refresh()
ThisForm.lblDay2.Caption = CDOW(This.Value)
ENDPROC
PROCEDURE txtD2.RightClick()
ThisForm.goObject = This
goFDatePicker.Top = ThisForm.giTop
goFDatePicker.Left = ThisForm.giLeft
goFDatePicker.goCallingForm = goFDOne
IF EMPTY(This.Value)
WITH goFDatePicker
.spnYear.Value = YEAR(DATE())
.spnMonth.Value = MONTH(DATE())
.spnDay.Value = DAY(DATE())
ENDWITH
ELSE
WITH goFDatePicker
.spnYear.Value = YEAR(This.Value)
.spnMonth.Value = MONTH(This.Value)
.spnDay.Value = DAY(This.Value)
ENDWITH
ENDIF
goFDatePicker.Show(1)
ENDPROC
PROCEDURE Load
SET DATE French
SET CENTURY ON
CREATE CURSOR csrDates (dDateOne D , dDateTwo D)
INSERT INTO csrDates VALUES (DATE() - 15, DATE() + 124)
ENDPROC
PROCEDURE Destroy
CLOSE ALL
Clear Events
ENDPROC
ENDDEFINE
*********************************************
DEFINE CLASS frmFDTwo AS Form
Caption = "Dates"
ShowTips = .T.
Top = 48
Left = 360
Height = 120
Width = 270
BorderStyle = 2
DataSession = 2
goObject = .NULL.
giTop = 180
giLeft = 180
ADD OBJECT lblRClick as Label WITH ;
Top = 12, Left = 12, AutoSize = .T., Caption = "Rightclick on any textbox to call the datepicker"
ADD OBJECT lblD1 as Label WITH ;
Top = 36, ;
Left = 12, ;
Caption = "Date 1"
ADD OBJECT lblD2 as Label WITH ;
Top = 72, ;
Left = 12, ;
Caption = "Date 2"
ADD OBJECT lblDay1 as Label WITH ;
Top = 36, Left = 174, Caption = ""
ADD OBJECT lblDay2 as Label WITH ;
Top = 72, Left = 174, Caption = ""
ADD OBJECT txtD1 as TextBox WITH ;
Top = 36, ;
Left = 60, ;
ReadOnly = .T., ;
ControlSource = "csrDates.dDateOne"
PROCEDURE txtD1.Refresh()
ThisForm.lblDay1.Caption = CDOW(This.Value)
ENDPROC
PROCEDURE txtD1.RightClick()
ThisForm.goObject = This
goFDatePicker.Top = ThisForm.giTop
goFDatePicker.Left = ThisForm.giLeft
goFDatePicker.goCallingForm = goFDTwo
IF EMPTY(This.Value)
WITH goFDatePicker
.spnYear.Value = YEAR(DATE())
.spnMonth.Value = MONTH(DATE())
.spnDay.Value = DAY(DATE())
ENDWITH
ELSE
WITH goFDatePicker
.spnYear.Value = YEAR(This.Value)
.spnMonth.Value = MONTH(This.Value)
.spnDay.Value = DAY(This.Value)
ENDWITH
ENDIF
goFDatePicker.Show(1)
ENDPROC
ADD OBJECT txtD2 as TextBox WITH ;
Top = 72, ;
Left = 60, ;
ReadOnly = .T., ;
ControlSource = "csrDates.dDateTwo"
PROCEDURE txtD2.Refresh()
ThisForm.lblDay2.Caption = CDOW(This.Value)
ENDPROC
PROCEDURE txtD2.RightClick()
ThisForm.goObject = This
goFDatePicker.Top = ThisForm.giTop
goFDatePicker.Left = ThisForm.giLeft
goFDatePicker.goCallingForm = goFDTwo
IF EMPTY(This.Value)
WITH goFDatePicker
.spnYear.Value = YEAR(DATE())
.spnMonth.Value = MONTH(DATE())
.spnDay.Value = DAY(DATE())
ENDWITH
ELSE
WITH goFDatePicker
.spnYear.Value = YEAR(This.Value)
.spnMonth.Value = MONTH(This.Value)
.spnDay.Value = DAY(This.Value)
ENDWITH
ENDIF
goFDatePicker.Show(1)
ENDPROC
PROCEDURE Load
SET DATE French
SET CENTURY ON
CREATE CURSOR csrDates (dDateOne D , dDateTwo D)
INSERT INTO csrDates VALUES (DATE() - 5, DATE() + 54)
ENDPROC
PROCEDURE Destroy
CLOSE ALL
Clear Events
ENDPROC
ENDDEFINE
*********************************************
DEFINE CLASS frmFDatePicker AS Form
Caption = "DatePicker"
ShowTips = .T.
Top = 150
Left = 150
Height = 150
Width = 240
BorderStyle = 2
MaxButton = .F.
MinButton = .F.
Closable = .F.
goCallingForm = .NULL.
ADD OBJECT lblDay as Label WITH Top = 24, Left = 36, Caption = "Day"
ADD OBJECT lblMonth as Label WITH Top = 24, Left = 90, Caption = "Month"
ADD OBJECT lblYear as Label WITH Top = 24, Left = 144, Caption = "Year"
ADD OBJECT spnDay as Spinner WITH ;
Top = 48, Left = 36, Width = 48, Value = DAY(DATE()), SpinnerLowValue = 1, SpinnerHighValue = 31, KeyboardLowValue = 1, KeyboardHighValue = 31
ADD OBJECT spnMonth as Spinner WITH ;
Top = 48, Left = 90, Width = 48, Value = MONTH(DATE()), SpinnerLowValue = 1, SpinnerHighValue = 12, KeyboardLowValue = 1, KeyboardHighValue = 12
ADD OBJECT spnYear as Spinner WITH ;
Top = 48, Left = 144, Width = 60, Value = YEAR(DATE()), SpinnerLowValue = 1900, SpinnerHighValue = 2050, KeyboardLowValue = 1900, KeyboardHighValue = 2050
ADD object cmdReturnDate as CommandButton WITH ;
Top = 90, Left = 12, Height = 48, width = ThisForm.Width - 24, Caption = "Return date"
PROCEDURE cmdReturnDate.Click()
LOCAL ldDate as Date, liYear as Integer, liMonth as Integer, liDay as Integer
If VarType(Thisform.goCallingForm) = "O" AND VARTYPE(ThisForm.goCallingForm.goObject) = "O"
liYear = ThisForm.spnYear.Value
liMonth = ThisForm.spnMonth.Value
liDay = ThisForm.spnDay.Value
ldDate = DATE(liYear, liMonth, liDay)
IF EMPTY(ldDate)
= MESSAGEBOX("Please check the date", 16, "Checking Date", 3000)
ELSE
WITH ThisForm.goCallingForm
.goObject.Value = ldDate
.goObject = .NULL.
.Refresh()
ENDWITH
ThisForm.Hide()
ENDIF
ENDIF
ENDPROC
PROCEDURE Moved()
WITH This.goCallingForm
.giLeft = This.Left
.giTop = This.Top
ENDWITH
ENDPROC
ENDDEFINE
*********************************************