Click here to get back home

How to get index of selected appointment inside calendar

 HomeNewsGroups | Search | About
 microsoft.public.smartphone.developer    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
How to get index of selected appointment inside calendar Kapil 09-27-2007
Get Chitika Premium
Posted by Kapil on September 27, 2007, 7:42 am
Please log in for more thread options
Hi,
This is kapil from India.How can i retreive the index of selected
appointment inside calendar application.

For e.g. When i open my calendar application which has some appointments
inside it.If i select second , it should return 2,if fourth is selected then
it should return 4 and so on.I m interested in index of currently seleted
appointment inside calendar.I m doing like below :For the time being i have
hard code it as 1...

I want this to be generalized..

hr = pPOOM->GetDefaultFolder(olFolderCalendar,&pFolder);
CHR(hr);

hr = pFolder->get_Items(&pItems);
CHR(hr);

hr = pItems->Add(reinterpret_cast<IDispatch**>(&pAppt));
CHR(hr);

pItems->get_Count(&cItems);
if(cItems != 0 )
{
///Here i want index (currently it is 1)
if (SUCCEEDED(pItems->Item(1, reinterpret_cast<IDispatch**>(&pAppt))))
{
hr = pAppt->get_Subject(&bstrSubject);
CHR(hr);
::MessageBoxW(NULL,bstrSubject,_T("Subject"),MB_OK);
}
}

Enumerating appointments is easy in that case count will help.But i m not
able to get index of currently selected appointment inside calendar.

Please help.I will be grateful to you all.

regards
kapil





Posted by Peter Foot [MVP] on September 27, 2007, 8:53 am
Please log in for more thread options
On Windows Mobile 5.0 and later you can use GetItemIndexFromOid to get the
index within a collection. For older versions the only way is to enumerate
the collection until you find the item which matches.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

> Hi,
> This is kapil from India.How can i retreive the index of selected
> appointment inside calendar application.
>
> For e.g. When i open my calendar application which has some appointments
> inside it.If i select second , it should return 2,if fourth is selected
> then
> it should return 4 and so on.I m interested in index of currently seleted
> appointment inside calendar.I m doing like below :For the time being i
> have
> hard code it as 1...
>
> I want this to be generalized..
>
> hr = pPOOM->GetDefaultFolder(olFolderCalendar,&pFolder);
> CHR(hr);
>
> hr = pFolder->get_Items(&pItems);
> CHR(hr);
>
> hr = pItems->Add(reinterpret_cast<IDispatch**>(&pAppt));
> CHR(hr);
>
> pItems->get_Count(&cItems);
> if(cItems != 0 )
> {
> ///Here i want index (currently it is 1)
> if (SUCCEEDED(pItems->Item(1, reinterpret_cast<IDispatch**>(&pAppt))))
> {
> hr = pAppt->get_Subject(&bstrSubject);
> CHR(hr);
> ::MessageBoxW(NULL,bstrSubject,_T("Subject"),MB_OK);
> }
> }
>
> Enumerating appointments is easy in that case count will help.But i m not
> able to get index of currently selected appointment inside calendar.
>
> Please help.I will be grateful to you all.
>
> regards
> kapil
>
>
>
>


Posted by Kapil on September 28, 2007, 1:33 am
Please log in for more thread options
Hi Peter,
Thankx for the reply.I used it but it did not help me may be i
m not using it correclty.Below is my code in the way i am using..

HRESULT hr ;
IFolder *pFolder;
IPOutlookApp2 *pPOOM = NULL;
IPOutlookItemCollection *pItems;
IAppointment *pAppt = NULL;

TCHAR tszStartDate[28];
TCHAR tszEndDate[28];

SYSTEMTIME stStart;
DATE bstrStart;
DATE bstrEnd;
BSTR bstrLocation;
BSTR bstrNote;
BSTR bstrSubject;
long bstrMins;
int cItems = 0;
long bstrSensitivity;
long bstrBusy;
DWORD index;
long oidPIM;
                
char msg[2];

hr = GetPOOM(&pPOOM);
CHR(hr);

hr = pPOOM->GetDefaultFolder(olFolderCalendar,&pFolder);
CHR(hr);

hr = pFolder->get_Items(&pItems);
CHR(hr);

hr = pItems->Add(reinterpret_cast<IDispatch**>(&pAppt));
CHR(hr);

pItems->get_Count(&cItems);
if(cItems != 0 )
{
        hr =GetItemIndexFromOid(pItems,oidPIM,&index);
        CHR(hr);
        sprintf(msg,"%ld",index);
        ::MessageBox(NULL,(LPCWSTR)msg,_T("Index"),MB_OK);

        if (SUCCEEDED(pItems->Item(1+index, reinterpret_cast<IDispatch**>(&pAppt))))
        {
                hr = pAppt->get_Subject(&bstrSubject);
                CHR(hr);
                ::MessageBoxW(NULL,bstrSubject,_T("Subject"),MB_OK);

        }
}

Please help..

regards
kapil




Posted by Peter Foot [MVP] on October 2, 2007, 6:45 am
Please log in for more thread options
What are you trying to achieve? If you want to get a specific item from it's
Oid then the most efficient way is to use GetItemFromOid exposed by the
IPOutlookApp interface.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

> Hi Peter,
> Thankx for the reply.I used it but it did not help me may be
> i
> m not using it correclty.Below is my code in the way i am using..
>
> HRESULT hr ;
> IFolder *pFolder;
> IPOutlookApp2 *pPOOM = NULL;
> IPOutlookItemCollection *pItems;
> IAppointment *pAppt = NULL;
>
> TCHAR tszStartDate[28];
> TCHAR tszEndDate[28];
>
> SYSTEMTIME stStart;
> DATE bstrStart;
> DATE bstrEnd;
> BSTR bstrLocation;
> BSTR bstrNote;
> BSTR bstrSubject;
> long bstrMins;
> int cItems = 0;
> long bstrSensitivity;
> long bstrBusy;
> DWORD index;
> long oidPIM;
>
> char msg[2];
>
> hr = GetPOOM(&pPOOM);
> CHR(hr);
>
> hr = pPOOM->GetDefaultFolder(olFolderCalendar,&pFolder);
> CHR(hr);
>
> hr = pFolder->get_Items(&pItems);
> CHR(hr);
>
> hr = pItems->Add(reinterpret_cast<IDispatch**>(&pAppt));
> CHR(hr);
>
> pItems->get_Count(&cItems);
> if(cItems != 0 )
> {
> hr =GetItemIndexFromOid(pItems,oidPIM,&index);
> CHR(hr);
> sprintf(msg,"%ld",index);
> ::MessageBox(NULL,(LPCWSTR)msg,_T("Index"),MB_OK);
>
> if (SUCCEEDED(pItems->Item(1+index,
> reinterpret_cast<IDispatch**>(&pAppt))))
> {
> hr = pAppt->get_Subject(&bstrSubject);
> CHR(hr);
> ::MessageBoxW(NULL,bstrSubject,_T("Subject"),MB_OK);
>
> }
> }
>
> Please help..
>
> regards
> kapil
>
>
>


Posted by Kapil on October 3, 2007, 12:59 am
Please log in for more thread options
Hi Peter,
Thankx for the reply.I have solved my problem.Thanx for your
guidance.I am grateful to you.

I have a question like when i select week under appointments ,it shows the
calendar with appointment listed on it.How can i read all the appointments
with in week.

Please guide.

regards
kapil

Similar ThreadsPosted
CSPROPERTY_BUFFER_DRIVER inside Windows Mobile 5.0 March 2, 2006, 5:46 am
reccurring appointment delete problem March 6, 2007, 5:36 am
Listview : Set selected item November 19, 2006, 2:52 pm
Create a Wi-Fi connection that can be selected ConnMgrMapConRef() May 10, 2007, 11:19 pm
How to change the name of the folder in Start Menu according to the language selected December 19, 2005, 6:44 am
Calendar June 25, 2005, 9:56 pm
about calendar and task October 25, 2005, 11:41 pm
Calendar Appointments November 18, 2006, 4:05 pm
Launch calendar in outlook? June 13, 2005, 10:35 pm
calendar commandline parameters February 27, 2007, 5:08 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap