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.
Trapping events on a ToleAuto object
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: Trapping events on a ToleAuto object
Reinaldo
As they said in the movie Major League .. "Wonder how you feel about the 'Good Ole Number 1'" ( try\Catch ), Also .. you can evaluate oErr on error.
Rick Lipkin
As they said in the movie Major League .. "Wonder how you feel about the 'Good Ole Number 1'" ( try\Catch ), Also .. you can evaluate oErr on error.
Rick Lipkin
Code: Select all
Try
oCn := CREATEOBJECT( "ADODB.Connection" )
Catch oErr
MsgInfo( "Could not create the ADO object for connection")
oDlg:End()
End Try
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
Re: Trapping events on a ToleAuto object
Thank you, Rick. My question is not how to trap and recover from an error. My question is how to trap the ocx's event. When the object is created using Tactivex():new() you can use bonEvent property to trap and act as you wish anytime an event is triggered by the component. I can't find how to do so when the object is created using create object. Perhaps createobject class can't handle events?
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
Re: Trapping events on a ToleAuto object
I think it will be easier to try and find out why is TActiveX():New() causing a GFP. If you have a codeJock ocx available you could recreate the gpf with this line:
I think the gpf happens inside activex.prg new() method at this line:
Can you help?
Thank you.
Code: Select all
::oCalexResources := tActiveX():New( ,"Codejock.CalendarResources.13.4.2" )
Code: Select all
::hActiveX = CreateActiveX( ::hWnd, cProgID, Self )
Thank you.
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Re: Trapping events on a ToleAuto object
Reinaldo
This is the code i use for showing multiple schedules , it is working OK
I use Harbour and msvc 2013
Hth
Richard
This is the code i use for showing multiple schedules , it is working OK
I use Harbour and msvc 2013
Hth
Richard
Code: Select all
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
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
Re: Trapping events on a ToleAuto object
Richard,
Thank you very much. Problem solved.
FWIW- I tried to simplify the code. Here it is:
BTW- are you working with events assigned to multiple resources?
Reinaldo.
Thank you very much. Problem solved.
FWIW- I tried to simplify the code. Here it is:
Code: Select all
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
BTW- are you working with events assigned to multiple resources?
Reinaldo.