Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Calendar
  New Posts New Posts RSS Feed - Possible New Feature
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Possible New Feature

 Post Reply Post Reply
Author
Message
RolandoE. View Drop Down
Groupie
Groupie
Avatar

Joined: 19 May 2003
Location: United States
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote RolandoE. Quote  Post ReplyReply Direct Link To This Post Topic: Possible New Feature
    Posted: 21 August 2005 at 11:25pm

Hi,

This functionality wasn't apparent when reviewing the documentation but I need to filter the calendar event to be displayed by user. I have a table called ApptTaskList and from there I can get a list of all calendar events by user. I would then like to display the calendar event which belong to the chosen user.

Is this possible with the present control or should I post this as a suggestion?

Thanks.



Edited by RolandoE.
Rolando E. Cruz-Marshall
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: 22 August 2005 at 9:55am
Hi Rolando,

As I understand you have your own database with events data and you need to display them in the CalendarControl.

In this case you cannot use DataBase data provider which is shipped with the Calendar control because it is designed to work with Access DB and expects some predefined DB tables structure.

We already got some questions about how to connect calendar control to custom database. To make this process more universal data providers mechanism will be reorganized in the next versions.

But for the current version (and for the future to) you can use another technique described below.
It is quite easy and straightforward but for big amounts of events in the database it will have not very good performance results (load speed and memory usage).
But for a few thousands events it works fine. Of course, in the new versions this problem will be fixed.


So, to use your custom database, you have to write your own function to populate CalendarControl from the DB and catch events like EventAdded, EventChanged, EventDeleted to update your DB contents when user makes some changes in the calendar.

Look at the example below which illustrates this idea:

void Populate(LPCTSTR pcszUserName)
{
    pWndCalendar->GetDataProvider()-& gt;RemoveAllEvents();
    
    // Read events for the specified user from your DB here
    // objEventsCollection - recordset object with events data

    while( !objEventsCollection->GetbEOF() )
    {
        DWORD dwEventID = <objEventsCollection("EventID")> or XTP_CALENDAR_UNKNOWN_EVENT_ID;

        CXTPCalendarEventPtr ptrEvent = CXTPCalendarData::CreateNewEvent(dwEventID);
               
        ptrEvent->SetStartTime = ...
        ...

        pWndCalendar->GetDataProvider().AddEvent(ptrEvent);
    }

    pWndCalendar->Populate();
}

Also you can advise to the following calendar notifications to update database:
    XTP_NC_CALENDAREVENTWASADDED
    XTP_NC_CALENDAREVENTWASDELETED
    XTP_NC_CALENDAREVENTWASCHANGED

Please see also Calendar Demo project and documentation how to work with them.

Also, look at the similar questions at http://forum.codejock.com/forum_posts.asp?TID=2735&PN=1

--
WBR,
Serge
Back to Top
RolandoE. View Drop Down
Groupie
Groupie
Avatar

Joined: 19 May 2003
Location: United States
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote RolandoE. Quote  Post ReplyReply Direct Link To This Post Posted: 22 August 2005 at 10:15am

Hi,

Thanks for the quick reply. Even though I already have an appointment table in my database I already was able to link it to the Event table created by this control.

What I'm looking to do is the following...

Since we are developing a multi-user application I would like to display only the events which belong to the person using the application. The way I see doing this (short of having multiple Calendar MDB files) is by passing a list of EventIDs to the Calendar control. This way the control will only display the specified events.

Thanks.

Rolando E. Cruz-Marshall
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: 22 August 2005 at 10:28am
Rolando,

Yes, it's clear what do you need. We are preparing almost identical piece of functionality for further releases. Currently you can only filter events coming into Calendar control in some customized manner. One of possible solutions is what I've mentioned above.

--
WBR,
Serge
Back to Top
RolandoE. View Drop Down
Groupie
Groupie
Avatar

Joined: 19 May 2003
Location: United States
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote RolandoE. Quote  Post ReplyReply Direct Link To This Post Posted: 02 October 2005 at 7:03pm

This is probably a dumb question but here goes!

The code you are referring to above...

void Populate(LPCTSTR pcszUserName)

Am I to create this code within one of my application's classes or within the Calendar class?

Rolando

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: 03 October 2005 at 6:03am
Rolando,

That should be your code, not a patch to Calendar sources. And you can insert it anywhere as you like , even inside Calendar class.

It can be a member of class derived from calendar, or a member of your view or dialog class, or even a global function, if this is convenient for you.

--
WBR,
Serge
Back to Top
RolandoE. View Drop Down
Groupie
Groupie
Avatar

Joined: 19 May 2003
Location: United States
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote RolandoE. Quote  Post ReplyReply Direct Link To This Post Posted: 03 October 2005 at 5:12pm

I should have known better than to ask that dumb question!!

Thanks for the answer. It actually began to make sence what I had to do after I gave your suggestion more thought.

Thanks anyway!!

Rolando E. Cruz-Marshall
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.266 seconds.