Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OLE Error
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00378336
Message ID:
00411643
Vues:
13
Andreas:

ON a Windows 98 & earlier system, the calendar control is likely msacal70.ocx (Access or Office 97). On my Win2000 box with Office 2000, the same control is mscal.ocx. By calling it as these code samples show, the EXE runs as long as 1 of the ocx's is registered on the system. The code in the INIT of a form that displays the Calendar control and the code in a procedure file AddCalendar: (Sorry about the formatting)

* BEGIN frmDateLookup.init()

* Calendar popup window.
*
* Parameters:
* pdStartDate Initial date to show. If not passed, the
* default is today's date.

lparameters pdStartDate

local lcCalendar

if not dodefault()
RETURN( .f. )
endif

set procedure to addCalendar additive
lcCalendar = "MSCAL.Calendar.7"
this.addobject('olcCalendar',"cCalendar",lcCalendar)
* Default the initial date, and set the return value.
if pcount() == 0
pdStartDate = date()
endif
this.dlReturnValue = pdStartDate

* Now that we have an initial date, set the calendar to start at it.
thisform.olcCalendar.year = year(pdStartDate)
thisform.olcCalendar.month = month(pdStartDate)
thisform.olcCalendar.day = day(pdStartDate)
thisform.olcCalendar.showtitle = .F.
RETURN( .t. )

* END frmDateLookup.init()

DEFINE CLASS CCalendar AS OLECONTROL

Height = 150
Left = 10
Top = 34
Width = 160
visible = .T.
tabindex = 1

PROCEDURE DblClick

Thisform.cmdOK.click()
ENDPROC

*** OLE Control Event ***

PROCEDURE KeyUp

* Parameters:
* pnKeyCode Key's scan (not inkey) code.
* pnShiftAltCtrl "bitmap" as follows:
* 0=Plain key (no shift, alt or ctrl).
* 1=Shift was down.
* 2=Alt was down.
* 4=Ctrl was down.
*
lparameters pnKeyCode, pnShiftAltCtrl

do case
case pnKeyCode == 34 and pnShiftAltCtrl == 0
* PageDown: Advance one month.
this.NextMonth()
thisform.btnToday.Enabled = .T.
case pnKeyCode == 33 and pnShiftAltCtrl == 0
* PageUp: Go back one month.
this.PreviousMonth()
thisform.btnToday.Enabled = .T.
case pnKeyCode == 36 and pnShiftAltCtrl == 0
* Home: Go to the current day.
this.Today()
thisform.btnToday.Enabled = .F.
case pnKeyCode == 34 and pnShiftAltCtrl == 1
* Shift+PageDown: Advance one year.
this.NextYear()
thisform.btnToday.Enabled = .T.
case pnKeyCode == 33 and pnShiftAltCtrl == 1
* Shift+PageUp: Go back one year.
this.PreviousYear()
thisform.btnToday.Enabled = .T.
case pnKeyCode == 27 and pnShiftAltCtrl == 0
* Esc: click the cancel button (cancel property being ignored somehow).
thisform.cmdCancel.click()
case pnKeyCode == 13 and pnShiftAltCtrl == 0
* Enter: click the OK button (default property being ignored somehow).
thisform.cmdOK.click()
endcase
ENDPROC
ENDDEFINE

HTH
Mike
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform