Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Sorta new to ActiveX, need some help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Sorta new to ActiveX, need some help

 Post Reply Post Reply
Author
Message
Mark19960 View Drop Down
Groupie
Groupie


Joined: 17 October 2007
Location: United States
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mark19960 Quote  Post ReplyReply Direct Link To This Post Topic: Sorta new to ActiveX, need some help
    Posted: 17 October 2007 at 3:07pm
Using an eval with Visual Dataflex for starters.
(yeah, no language support.. I know :()

Myself and a few others have been trying to get these controls to work and are unfortunately being held hostage by those that have figured it out for ca$h.

But that is all water under the bridge.
This is a pet project of mine, hopefully before the eval runs out :)

This is what we have that works... (loading from an access db)
This code is in a button:

Boolean bOpen bOK
            Handle hoData_Prov hoWorkSpace
            String sWork sConString
            Variant vData_Prov
   
            //Set connection string to a sample Access db
            Get phoWorkspace of ghoApplication to hoWorkSpace
            Get psProgramPath of hoWorkSpace to sWork           
            Move ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sWork + "\AccessSample.mdb") to sConString
            Send ComSetDataProvider of oComCalendarControl1 sConString
   
            //Get Data Provider object and connect to a VDF side Object
            Get Create U_cComCalendarDataProvider to hoData_Prov
                Get ComDataProvider of oComCalendarControl1 to vData_Prov
                Set pvComObject of hoData_Prov to vData_Prov
           
                Get ComOpen of hoData_Prov to bOpen
                If (not(bOpen)) Begin
                    Get ComCreate of hoData_Prov to bOK
                End
            Send Destroy of hoData_Prov
   
            //Populate the Visual Control
            Set ComViewType of oComCalendarControl1 to OLExtpCalendarWorkWeekView
            Send ComPopulate of oComCalendarControl1

So, this works and draws the data contained in the example database just fine.

Now, I am trying to get the custom provider working and just throw something on the screen manually, and this is what I have:
(yes, it is bad....)

Boolean bOpen bOK
            Handle hoData_Prov hoWorkSpace
            String sWork sConString
            Variant vData_Prov
   
          
            Get phoWorkspace of ghoApplication to hoWorkSpace
            Get psProgramPath of hoWorkSpace to sWork           
            Move ("Provider=Custom;") to sConString
            Send ComSetDataProvider of oComCalendarControl1 sConString
   
            //Get Data Provider object and connect to a VDF side Object
            Get Create U_cComCalendarDataProvider to hoData_Prov
                Get ComDataProvider of oComCalendarControl1 to vData_Prov
                Set pvComObject of hoData_Prov to vData_Prov
           
                Get ComOpen of hoData_Prov to bOpen
                If (not(bOpen)) Begin
                    Get ComCreate of hoData_Prov to bOK
                End
           
            Handle hEvent
            Variant vEvent
            DateTime dtVar dtEnd
            Move (CurrentDateTime()) to dtVar
            Integer iID iD
            Move "999" to iD
           
            Move (DateSetMillisecond(dtVar, 00))   to dtEnd
            Move (DateSetSecond(dtVar, 00))        to dtEnd
            Move (DateSetMinute(dtVar, 0))        to dtEnd
            Move (DateSetHour  (dtVar, 17))        to dtEnd
            Move (DateSetDay   (dtVar, 17))        to dtEnd
            Move (DateSetMonth (dtVar, 10))         to dtEnd
            Move (DateSetYear  (dtVar, 2007))      to dtEnd


           
           
            Get Create U_cComCalendarEvent to hEvent
            Get ComCreateEventEx of hoData_Prov iD to vEvent
            Set pvComObject of hEvent to vEvent
   
            Set ComSubject of hEvent to "test"
            Set ComLocation of hEvent to "test1"
            Set ComStartTime of hEvent to dtVar
            Set ComEndTime of hEvent to dtEnd
            Get ComScheduleID of hEvent to iID
           
            //Populate the Visual Control
            Set ComViewType of oComCalendarControl1 to OLExtpCalendarWorkWeekView
            Send ComPopulate of oComCalendarControl1


And, this is what I have...
My lack of understanding of how this control works, coupled with my ActiveX knowledge being nonexistant does not help me.

I am, a C programmer.... not a .NET or C# programmer or VB for that matter so the examples or doc do not really do much for me other than give me syntax :(

So, looking at this code from an alien language, can you guys tell me if I am at least doing things in the appropriate order, looking at the code that DOES work?

Any hints would be helpful :)


Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 17 October 2007 at 6:17pm
Have you read this article: http://www.codejock.com/support/articles/com/calendar/cp_3.asp?

--
WBR,
Serge
Back to Top
Mark19960 View Drop Down
Groupie
Groupie


Joined: 17 October 2007
Location: United States
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mark19960 Quote  Post ReplyReply Direct Link To This Post Posted: 17 October 2007 at 7:57pm
Originally posted by sserge sserge wrote:

Have you read this article: http://www.codejock.com/support/articles/com/calendar/cp_3.asp?

--
WBR,
Serge


Actually, I have... and that document says that if RetrieveDayEvents returns an empty events collection then the control will not display anything.

So, I added:
Variant vTest
Get ComRetrieveDayEvents of hoData_Prov dtVar to vTest
If (vTest = OLE_VT_EMPTY) Showln "vtest = empty"

Thing is, that Dataflex throws an error on that because there is actually
'something' in the variable, it's just not 'OLE_VT_EMPTY' which is defined as '0'

I also have:

Procedure OnComDoCreateEvent Variant llpEvent Integer ByRef llNewEventID Boolean ByRef llbResult
            Showln "here"
End_Procedure

In the object and it never gets fired.
If I saw this getting fired I would call that progress, but it never gets fired.
Other events fire, like mouse clicks and moves and such, just not any of these.

Trying to see what a 'Variant' actually *IS* in dataflex is like the boy Oliver asking for more...... your not going to get it.
It just does not give you a hint, all I can say is that what it contains is something that looks to me, as a C programmer like a memory address.

Back to Top
Mark19960 View Drop Down
Groupie
Groupie


Joined: 17 October 2007
Location: United States
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mark19960 Quote  Post ReplyReply Direct Link To This Post Posted: 18 October 2007 at 12:26am
I have cleaned this up a lot, and explained what *should* be happening in the code.

As far as I can tell I must not be sending or setting something in this basic example.
At the bottom when I try to get the data provider object using 'DataProvider' it returns the same object that is created in the beginning.
So, as far as the objects all being linked and such I do believe that is actually working, even if DataFlex is a tad excessive in the way you have to do it.

Again, this is in a button...

On another note I have been able to do other things like utilize the hittest objects accessing them in the same fashion here, so I am pretty sure I am doing it the right way.
Is there any fields I am not setting that are required for it to draw them?

I have a feeling I am not far off the answer here.

Quote
        Procedure OnClick
            String sConString
            Variant vDataProvider vEvent
            Handle hoDataProvider hoEvent
            
            Move ("Provider=Custom;") to sConString
            Send ComSetDataProvider of oComCalendarControl1 sConString
            // create data provider object
            Get Create U_cComCalendarDataProvider to hoDataProvider
            // get data provider object
            Get ComDataProvider of oComCalendarControl1 to vDataProvider
            // link data provider object to our dataflex object
            Set pvComObject of hoDataProvider to vDataProvider
           
            // create calendar event object
            Get Create U_cComCalendarEvent to hoEvent
            // get new event object from the data provider
            Get ComCreateEvent of hoDataProvider to vEvent
            // link the new event object to a dataflex object
            Set pvComObject of hoEvent to vEvent
           
            // make the event....
            DateTime dtStart
            DateTime dtStop
           
            // note to self: see if this can be shortened.
            Move (DateSetMillisecond(dtStart, 00))     to dtStart
            Move (DateSetSecond(dtStart, 00))          to dtStart
            Move (DateSetMinute(dtStart, 00))          to dtStart
            Move (DateSetHour  (dtStart, 10))          to dtStart
            Move (DateSetDay   (dtStart, 18))          to dtStart
            Move (DateSetMonth (dtStart, 10))          to dtStart
            Move (DateSetYear  (dtStart, 2007))        to dtStart

            Move (DateSetMillisecond(dtStop, 00))     to dtStop
            Move (DateSetSecond(dtStop, 00))          to dtStop
            Move (DateSetMinute(dtStop, 00))          to dtStop
            Move (DateSetHour  (dtStop, 11))          to dtStop
            Move (DateSetDay   (dtStop, 18))          to dtStop
            Move (DateSetMonth (dtStop, 10))          to dtStop
            Move (DateSetYear  (dtStop, 2007))        to dtStop
           
            // set some stuff in the event object
            Set ComSubject of hoEvent to "test subject"
            Set ComLocation of hoEvent to "test location"
            Set ComStartTime of hoEvent to dtStart
            Set ComEndTime of hoEvent to dtStop
          
           
            // debug: if this really worked then in theory, per the docs
            // 'ComDataProvider' should return the above data provider object
            // and we should see the same address in the debugger.
            // and it does!.......

            Variant vProvider
            Get ComDataProvider of hoEvent to vProvider
           
            // add this event? (cross fingers)
            Send ComAddEvent of hoDataProvider vEvent
           
            // populate the control (hopefully)
            Send ComPopulate of oComCalendarControl1           
           
        End_Procedure

 
Back to Top
Mark19960 View Drop Down
Groupie
Groupie


Joined: 17 October 2007
Location: United States
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mark19960 Quote  Post ReplyReply Direct Link To This Post Posted: 20 October 2007 at 12:45pm
I did get this to work...
Note that I am not sending:

Get ComOpen of hoDataProvider to bOpen

Oops. :)

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.