Hi.
I usually trap Ole events using :bOnEvent property of TActiveX() object. How can I trap events when the object is created using CreateObject()?
Thank you,
Reinaldo.
Try
oCn := CREATEOBJECT( "ADODB.Connection" )
Catch oErr
MsgInfo( "Could not create the ADO object for connection")
oDlg:End()
End Try
::oCalexResources := tActiveX():New( ,"Codejock.CalendarResources.13.4.2" )
::hActiveX = CreateActiveX( ::hWnd, cProgID, Self )
METHOD buildMultiSchedule() CLASS TPLANCJ
local oSchedules , ;
oRes := {} , ;
n := 0
IF ! PLANPREF->MULTIPERS // si pas multi utilisateurs
RETURN NIL
ENDIF
::objResources := nil
::objResources = createobject("Codejock.CalendarResources.15.0.2")
::oRes1 := nil
::oRes1 = createobject("Codejock.CalendarResource.15.0.2")
::oRes1:SetDataProvider2( "Provider=custom", .T. )
if ! ::oRes1:DataProvider:open()
::oRes1:DataProvider:Create()
endif
oSchedules := ::oRes1:DataProvider:Schedules()
DBSELECTAREA("AGPERS")
AGPERS->(ORDSETFOCUS("NOM") )
AGPERS->(DBGOTOP())
n := 0
WHILE ! AGPERS->(EOF())
IF ! AGPERS->NOPLANNING .AND. AGPERS->AFFICHE # SPACE(5) .AND. n < 11
with object oSchedules
:AddNewSchedule( ALLTRIM(AGPERS->AFFICHE) ) // name of the person
n++
end
ENDIF
AGPERS->(DBSKIP())
ENDDO
IF n = 0
MSGSTOP("Fichier personnel incohérent pour le planning, veuillez renseigner les critères d'affichage pour chaque personne")
RETURN NIL
ENDIF
::oRes1:DataProvider:save()
n := 0
AGPERS->(DBGOTOP())
WHILE ! AGPERS->(EOF())
IF ! AGPERS->NOPLANNING .AND. AGPERS->AFFICHE # SPACE(5) .AND. n < 11
n++
IF n = 1
AADD(ORES,nil)
::oRes1:Name = oSchedules:Item(n -1):Name
::oRes1:ScheduleIDs:Add(AGPERS->NUMERO) // id of the person
::objResources:Add(::oRes1)
ELSE
AADD(ORES,createobject("Codejock.CalendarResource.15.0.2"))
oRes[n]:SetDataProvider( ::oRes1:DataProvider, .F. )
oRes[n]:Name = oSchedules:Item(n -1):Name
oRes[n]:ScheduleIDs:Add(AGPERS->NUMERO)
::objResources:Add(oRes[n])
ENDIF
ENDIF
AGPERS->(DBSKIP())
ENDDO
FOR n = 1 TO LEN(ORES)
IF ORES[n] # nil
oRes[n] := nil // destroy object
ENDIF
NEXT
::oCalex:SetMultipleResources( ::objResources )
::oCalex:populate()
return nil
METHOD New() CLASS MpCal
...
::aSchedules := ::oSchdls:SaveToArray( { |o| o:id } )
aTmp := ExecuteSqlScript( "Select label, id from schdl_lbls", .f. )
aEval( aTmp, { |e,n| hSet( ::hLabels, alltrim( e[ 1 ] ), e[ 2 ] ) } )
::BuildPanels() //two panels -left and right
::RegisterOcx() //Registers the CalendarGlobalSettings ocx and license
::BuildCalex() //actual calendar on the right panel
::BuildDatePicker() //datepicker control on the left
::BuildStdDialogs() //initializes object with various CodeJock standard dialogs to be used
//work with multiple schedules only when multiple schedules have been created
IF !EMPTY( ::aSchedules ) ;::SetupForMultiResources() ;ENDIF
::oCalex:Populate()
::oCalex:RedrawControl()
RETURN SELF
//---------------------------------------------------//
METHOD SetupForMultiResources() CLASS MpCal
local oRes, oData, oErr
local oResCollection2bDestroyed := {} //temporary collection used only to destroy used objects
local cCfgFile
TRY
//collection of schedule resources (mostlikely people or rooms)
::oCalexResources := CreateObject( "Codejock.CalendarResources.13.4.2" )
CATCH oErr
WriteErrorLog( oErr )
Return NIL
END
oRes := ::CreateScheduleResource()
oRes:SetDataProvider2( "Provider=custom", .T. )
oData := oRes:DataProvider
oData:Open()
::oSchedules := oData:Schedules()
::oSchedules:AddNewSchedule( "Un-Assigned" )
oRes:Name := ::oSchedules:Item( 0 ):Name
oRes:ScheduleIDs:Add( 0 )
::oCalexResources:Add( oRes )
AADD( oResCollection2bDestroyed, oRes )
AEVAL( ::aSchedules, { |e,n| ::oSchedules:AddNewSchedule( e ),;
AADD( oResCollection2bDestroyed, ::CreateScheduleResource() ),;
ATAIL( oResCollection2bDestroyed ):SetDataProvider( oData, .T. ),;
ATAIL( oResCollection2bDestroyed ):Name := e ,;
ATAIL( oResCollection2bDestroyed ):ScheduleIDs:Add( n ),;
::oCalexResources:Add( ATAIL( oResCollection2bDestroyed ) ) } )
::oCalex:SetMultipleResources( ::oCalexResources )
AEVAL( oResCollection2bDestroyed, { |e| e := NIL } )
oResCollection2bDestroyed := NIL
RETURN NIL
//---------------------------------------------------//
METHOD CreateScheduleResource() CLASS MpCal
local oRes, oErr
TRY
oRes := CreateObject( "Codejock.CalendarResource.13.4.2" )
CATCH oErr
WriteErrorLog( oErr )
MsgInfo( "Missing standard dialogs components" )
END
RETURN oRes
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 72 guests