RandyDeWitt
IS-IT--Management
I have a question concerning the usage of the calendar control in VFP 7.0. I have created the following container inside of my standard class file.
The behavior I want is to press the down arrow on my container, have the calendar pop up, select a date, then have the calendar disappear.
If I run the code through the debugger, everything appears correct including transferring the value back to date control. It appears that after I transfer the value, then set the visible flag to .F. in the ole control, the calendar disappears then reappears for no apparent reason. I can no longer select a date using the calendar. If I cycle the display button, it operates as expected.
I am at a loss as to why the calendar redisplays after I set Visible = .F. Any insight would be appreciated.
Here is the definition for my date class.
**************************************************
*-- Class: xcntdate (c:\vfp7projects\honda\genclass.vcx)
*-- ParentClass: xcnt (c:\vfp7projects\class\dnuroot.vcx)
*-- BaseClass: container
*-- Time Stamp: 08/01/05 05:02:11 PM
*
DEFINE CLASS xcntdate AS xcnt
Width = 155
Height = 183
BackStyle = 0
BorderWidth = 0
TabStop = .T.
Name = "xcntdate"
*-- Defines the control source for txtDate.
cdatecontrol = .F.
ADD OBJECT txtdate AS xtxt WITH ;
Height = 23, ;
Left = 0, ;
TabIndex = 1, ;
Top = 0, ;
Width = 108, ;
Name = "txtDate"
ADD OBJECT imgdropcal AS ximg WITH ;
Picture = "other\ddlb.bmp", ;
Height = 22, ;
Left = 120, ;
Top = 2, ;
Width = 17, ;
Name = "imgDropCal"
ADD OBJECT olecal AS olecontrol WITH ;
Top = 36, ;
Left = 0, ;
Height = 145, ;
Width = 146, ;
TabIndex = 2, ;
TabStop = .T., ;
Name = "oleCal"
*-- Generic method to show / hide calendar control.
PROCEDURE showcal
*\ Method designed to show or hide the ole calendar control. It examines the
*\ visible property of olecal to decide what to do. If visible, it hides the calendar
*\ if !visible, it shows the calendar.
WITH this
IF .oleCal.Visible
*\ Calendar visible, move value back to txtDate
.txtDate.Value = TTOD(.oleCal.Object.Value)
.oleCal.Enabled = .F.
.oleCal.Visible = .F.
ELSE
*\ Calendar !visible, initialize value from txtDate and display.
.oleCal.Object.Value = .txtDate.Value
.oleCal.refresh()
.oleCal.Enabled = .T.
.oleCal.Visible = .T.
ENDIF
ENDWITH
ENDPROC
PROCEDURE Init
*\ Init method sets the control source for txtDate and initializes lCalVisible
WITH this
.txtDate.ControlSource = .cDateControl
.oleCal.Enabled = .F.
.oleCal.Visible = .F.
.oleCal.Refresh()
ENDWITH
ENDPROC
PROCEDURE txtdate.Refresh
*\ Transfer value to oleCal object.
WITH this
.Parent.oleCal.oBJECT.Value = .Value
.Parent.oleCal.refresh()
ENDWITH
ENDPROC
PROCEDURE txtdate.LostFocus
*\ Transfer value to oleCal object.
WITH this
.Parent.oleCal.oBJECT.Value = .Value
.Parent.oleCal.refresh()
ENDWITH
ENDPROC
PROCEDURE imgdropcal.Click
*\ Show/Hide oleCal control
this.Parent.showcal()
ENDPROC
PROCEDURE olecal.AfterUpdate
*** ActiveX Control Event ***
this.Parent.showcal()
ENDPROC
ENDDEFINE
*
*-- EndDefine: xcntdate
**************************************************
The behavior I want is to press the down arrow on my container, have the calendar pop up, select a date, then have the calendar disappear.
If I run the code through the debugger, everything appears correct including transferring the value back to date control. It appears that after I transfer the value, then set the visible flag to .F. in the ole control, the calendar disappears then reappears for no apparent reason. I can no longer select a date using the calendar. If I cycle the display button, it operates as expected.
I am at a loss as to why the calendar redisplays after I set Visible = .F. Any insight would be appreciated.
Here is the definition for my date class.
**************************************************
*-- Class: xcntdate (c:\vfp7projects\honda\genclass.vcx)
*-- ParentClass: xcnt (c:\vfp7projects\class\dnuroot.vcx)
*-- BaseClass: container
*-- Time Stamp: 08/01/05 05:02:11 PM
*
DEFINE CLASS xcntdate AS xcnt
Width = 155
Height = 183
BackStyle = 0
BorderWidth = 0
TabStop = .T.
Name = "xcntdate"
*-- Defines the control source for txtDate.
cdatecontrol = .F.
ADD OBJECT txtdate AS xtxt WITH ;
Height = 23, ;
Left = 0, ;
TabIndex = 1, ;
Top = 0, ;
Width = 108, ;
Name = "txtDate"
ADD OBJECT imgdropcal AS ximg WITH ;
Picture = "other\ddlb.bmp", ;
Height = 22, ;
Left = 120, ;
Top = 2, ;
Width = 17, ;
Name = "imgDropCal"
ADD OBJECT olecal AS olecontrol WITH ;
Top = 36, ;
Left = 0, ;
Height = 145, ;
Width = 146, ;
TabIndex = 2, ;
TabStop = .T., ;
Name = "oleCal"
*-- Generic method to show / hide calendar control.
PROCEDURE showcal
*\ Method designed to show or hide the ole calendar control. It examines the
*\ visible property of olecal to decide what to do. If visible, it hides the calendar
*\ if !visible, it shows the calendar.
WITH this
IF .oleCal.Visible
*\ Calendar visible, move value back to txtDate
.txtDate.Value = TTOD(.oleCal.Object.Value)
.oleCal.Enabled = .F.
.oleCal.Visible = .F.
ELSE
*\ Calendar !visible, initialize value from txtDate and display.
.oleCal.Object.Value = .txtDate.Value
.oleCal.refresh()
.oleCal.Enabled = .T.
.oleCal.Visible = .T.
ENDIF
ENDWITH
ENDPROC
PROCEDURE Init
*\ Init method sets the control source for txtDate and initializes lCalVisible
WITH this
.txtDate.ControlSource = .cDateControl
.oleCal.Enabled = .F.
.oleCal.Visible = .F.
.oleCal.Refresh()
ENDWITH
ENDPROC
PROCEDURE txtdate.Refresh
*\ Transfer value to oleCal object.
WITH this
.Parent.oleCal.oBJECT.Value = .Value
.Parent.oleCal.refresh()
ENDWITH
ENDPROC
PROCEDURE txtdate.LostFocus
*\ Transfer value to oleCal object.
WITH this
.Parent.oleCal.oBJECT.Value = .Value
.Parent.oleCal.refresh()
ENDWITH
ENDPROC
PROCEDURE imgdropcal.Click
*\ Show/Hide oleCal control
this.Parent.showcal()
ENDPROC
PROCEDURE olecal.AfterUpdate
*** ActiveX Control Event ***
this.Parent.showcal()
ENDPROC
ENDDEFINE
*
*-- EndDefine: xcntdate
**************************************************