Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Calendar
  New Posts New Posts RSS Feed - Trying to load all records into calendar at once
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Trying to load all records into calendar at once

 Post Reply Post Reply
Author
Message
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post Topic: Trying to load all records into calendar at once
    Posted: 22 March 2010 at 5:45pm
Hello all,

I'm trying to load all calendar records into the control when the application starts, to speed up loading time, but I can't seem to get it to work properly.

Can someone spot what I'm doing wrong? Thanks in advance!

The idea is to create arrays of events for days and then add them to the cache, so that the control could use them. Maybe I need a different approach altogether?

Some code (not really working properly):


        CArray<CXTPCalendarEvent *> plannerEntries;
        // populate the array from the database here, entries are sorted based on start time

        COleDateTime dtCur;
        dtCur.m_dt = 0;
        CXTPCalendarEvents * ptrEvents = NULL;

        int count = plannerEntries.GetCount();
        for(int i=0; i<count; i++)
        {
            CXTPCalendarEvent * pEvent = plannerEntries.GetAt(i);
            if(pEvent)
            {
                COleDateTime dtEvent = pEvent->GetStartTime();
                COleDateTime dtToCompare = dtEvent;
                dtToCompare.SetDateTime(dtEvent.GetYear(), dtEvent.GetMonth(), dtEvent.GetDay(), 0, 0, 0);

                if(dtCur.m_dt == 0 ||
                    dtCur.m_dt != dtToCompare.m_dt)
                {
                    if(ptrEvents)
                    {
                        if(dtCur.m_dt != 0)
                        {
                            m_cache.AddToCache(ptrEvents, dtCur);
                        }
                    }

                    dtCur = dtToCompare;

                    if(ptrEvents)
                        delete ptrEvents;
                    ptrEvents = new CXTPCalendarEvents;
                }

                if(ptrEvents)
                {
                    ptrEvents->Add(pEvent, FALSE);
                }
            }
        }

        if(ptrEvents)
        {
            if(dtCur.m_dt != 0)
            {
                m_cache.AddToCache(ptrEvents, dtCur);
            }

            delete ptrEvents;
        }


This is in my custom data provider of course.
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)
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.203 seconds.