Pocketoutlook Add-in

N

Neelima Godugu

Hi All,
I am trying to extend the menu's in PocketOutlook Calendar by using
CePimCommand funtion.
So far i have gotten to the point where I have been able to Launch my CF exe
when the Menu options are tapped.
The only problem I have is when my CF EXE is already running. In this case,
the App just comes into focus and the code that I included in the Main
method is not executed. Could anybody suggest a work around for this
problem.
Following is the CEPIMCOMMAND.DLL code
void CePimCommand(HWND hWnd,
PIMTYPE ptData,
UINT uDataCount,
HANDLE * rghData,
void * pReserved)
{

//Convert ceoid to string
CEOID hitem = ((CEOID)*rghData);
wchar_t strCEOID[40];
_itow(hitem,strCEOID,10);
//Modify TEXT(...) Appropriately
LPTSTR commandType = TEXT("TSKUPDTSK ");
wchar_t commandParams[100];
_tcscat(commandParams,commandType);
_tcscat(commandParams,strCEOID);

//Launch Dovarri
CreateProcess(TEXT("\\My
documents\\Dovarri\\dovarri.exe"),commandParams,NULL,
NULL,false,NULL,NULL,NULL,NULL,NULL);

}
//FOLLOWING IS THE CODE IN MY MAIN method
static void Main(string [] args)

{

gArgs =args;

if(gArgs.Length > 0 && gArgs.Length == 2 )

{

//Invoked from Pocket Outlook


string menuOption = gArgs[0];

string oid = gArgs[1];

OutlookApplication app = new OutlookApplication();

switch(menuOption)

{

case "CALADDAPPT":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Activity to that
Account");

break;

case "CALUPDAPPT":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Activity as
Personal");

Appointment appt
=(Appointment)app.GetItemFromOid(Int32.Parse(oid),ItemType.Appointment);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Appointment,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "CONADDCON":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Contact to that Account");

break;

case "CONUPDCON":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Contact as Personal");

Contact con
=(Contact)app.GetItemFromOid(Int32.Parse(oid),ItemType.Contact );

//Check if the contact is present in DB

if(LookUPItem(ItemType.Contact ,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "TSKADDTSK":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Task to that Account");

break;

case "TSKUPDTSK":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Task as Personal");

Task tsk =(Task)app.GetItemFromOid(Int32.Parse(oid),ItemType.Task);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Task,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

}

}

Application.Run(new Form1());


}

TIA
Neelima
 
S

Shanti

Put the code in a sub and call it from both main() and the event for
GotFocus.

Neelima Godugu said:
Hi All,
I am trying to extend the menu's in PocketOutlook Calendar by using
CePimCommand funtion.
So far i have gotten to the point where I have been able to Launch my CF exe
when the Menu options are tapped.
The only problem I have is when my CF EXE is already running. In this case,
the App just comes into focus and the code that I included in the Main
method is not executed. Could anybody suggest a work around for this
problem.
Following is the CEPIMCOMMAND.DLL code
void CePimCommand(HWND hWnd,
PIMTYPE ptData,
UINT uDataCount,
HANDLE * rghData,
void * pReserved)
{

//Convert ceoid to string
CEOID hitem = ((CEOID)*rghData);
wchar_t strCEOID[40];
_itow(hitem,strCEOID,10);
//Modify TEXT(...) Appropriately
LPTSTR commandType = TEXT("TSKUPDTSK ");
wchar_t commandParams[100];
_tcscat(commandParams,commandType);
_tcscat(commandParams,strCEOID);

//Launch Dovarri
CreateProcess(TEXT("\\My
documents\\Dovarri\\dovarri.exe"),commandParams,NULL,
NULL,false,NULL,NULL,NULL,NULL,NULL);

}
//FOLLOWING IS THE CODE IN MY MAIN method
static void Main(string [] args)

{

gArgs =args;

if(gArgs.Length > 0 && gArgs.Length == 2 )

{

//Invoked from Pocket Outlook


string menuOption = gArgs[0];

string oid = gArgs[1];

OutlookApplication app = new OutlookApplication();

switch(menuOption)

{

case "CALADDAPPT":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Activity to that
Account");

break;

case "CALUPDAPPT":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Activity as
Personal");

Appointment appt
=(Appointment)app.GetItemFromOid(Int32.Parse(oid),ItemType.Appointment);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Appointment,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "CONADDCON":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Contact to that Account");

break;

case "CONUPDCON":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Contact as Personal");

Contact con
=(Contact)app.GetItemFromOid(Int32.Parse(oid),ItemType.Contact );

//Check if the contact is present in DB

if(LookUPItem(ItemType.Contact ,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "TSKADDTSK":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Task to that Account");

break;

case "TSKUPDTSK":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Task as Personal");

Task tsk =(Task)app.GetItemFromOid(Int32.Parse(oid),ItemType.Task);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Task,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

}

}

Application.Run(new Form1());


}

TIA
Neelima
 
C

Chris Tacke, eMVP

The problem is that the PocketPC is a pain in the ass and the CF enforces
that apps are singletons. It brings your current running app to the fore
and kills the new instance trying to start before Main is even run. CE
itself doesn't have this behavior, and I personally wish they left it to the
developer to enforce singleton apps for logo certification. With the method
they've implemented we can't get notifications for CeRunAppAtTime,
CeRunAppAtEvent and others.

--
Chris Tacke, eMVP
Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net

Neelima Godugu said:
Hi All,
I am trying to extend the menu's in PocketOutlook Calendar by using
CePimCommand funtion.
So far i have gotten to the point where I have been able to Launch my CF exe
when the Menu options are tapped.
The only problem I have is when my CF EXE is already running. In this case,
the App just comes into focus and the code that I included in the Main
method is not executed. Could anybody suggest a work around for this
problem.
Following is the CEPIMCOMMAND.DLL code
void CePimCommand(HWND hWnd,
PIMTYPE ptData,
UINT uDataCount,
HANDLE * rghData,
void * pReserved)
{

//Convert ceoid to string
CEOID hitem = ((CEOID)*rghData);
wchar_t strCEOID[40];
_itow(hitem,strCEOID,10);
//Modify TEXT(...) Appropriately
LPTSTR commandType = TEXT("TSKUPDTSK ");
wchar_t commandParams[100];
_tcscat(commandParams,commandType);
_tcscat(commandParams,strCEOID);

//Launch Dovarri
CreateProcess(TEXT("\\My
documents\\Dovarri\\dovarri.exe"),commandParams,NULL,
NULL,false,NULL,NULL,NULL,NULL,NULL);

}
//FOLLOWING IS THE CODE IN MY MAIN method
static void Main(string [] args)

{

gArgs =args;

if(gArgs.Length > 0 && gArgs.Length == 2 )

{

//Invoked from Pocket Outlook


string menuOption = gArgs[0];

string oid = gArgs[1];

OutlookApplication app = new OutlookApplication();

switch(menuOption)

{

case "CALADDAPPT":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Activity to that
Account");

break;

case "CALUPDAPPT":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Activity as
Personal");

Appointment appt
=(Appointment)app.GetItemFromOid(Int32.Parse(oid),ItemType.Appointment);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Appointment,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "CONADDCON":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Contact to that Account");

break;

case "CONUPDCON":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Contact as Personal");

Contact con
=(Contact)app.GetItemFromOid(Int32.Parse(oid),ItemType.Contact );

//Check if the contact is present in DB

if(LookUPItem(ItemType.Contact ,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "TSKADDTSK":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Task to that Account");

break;

case "TSKUPDTSK":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Task as Personal");

Task tsk =(Task)app.GetItemFromOid(Int32.Parse(oid),ItemType.Task);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Task,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

}

}

Application.Run(new Form1());


}

TIA
Neelima
 
P

Peter Foot [MVP]

One solution would be to create a launcher exe which checks if the program
is already running and if so negotiates with a MessageWindow in the .NETCF
application. Like Chris says - a pain in the ass.

Peter

--
Peter Foot
Windows Embedded MVP

www.inthehand.com | www.opennetcf.org

Chris Tacke said:
The problem is that the PocketPC is a pain in the ass and the CF enforces
that apps are singletons. It brings your current running app to the fore
and kills the new instance trying to start before Main is even run. CE
itself doesn't have this behavior, and I personally wish they left it to the
developer to enforce singleton apps for logo certification. With the method
they've implemented we can't get notifications for CeRunAppAtTime,
CeRunAppAtEvent and others.

--
Chris Tacke, eMVP
Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net

Neelima Godugu said:
Hi All,
I am trying to extend the menu's in PocketOutlook Calendar by using
CePimCommand funtion.
So far i have gotten to the point where I have been able to Launch my CF exe
when the Menu options are tapped.
The only problem I have is when my CF EXE is already running. In this case,
the App just comes into focus and the code that I included in the Main
method is not executed. Could anybody suggest a work around for this
problem.
Following is the CEPIMCOMMAND.DLL code
void CePimCommand(HWND hWnd,
PIMTYPE ptData,
UINT uDataCount,
HANDLE * rghData,
void * pReserved)
{

//Convert ceoid to string
CEOID hitem = ((CEOID)*rghData);
wchar_t strCEOID[40];
_itow(hitem,strCEOID,10);
//Modify TEXT(...) Appropriately
LPTSTR commandType = TEXT("TSKUPDTSK ");
wchar_t commandParams[100];
_tcscat(commandParams,commandType);
_tcscat(commandParams,strCEOID);

//Launch Dovarri
CreateProcess(TEXT("\\My
documents\\Dovarri\\dovarri.exe"),commandParams,NULL,
NULL,false,NULL,NULL,NULL,NULL,NULL);

}
//FOLLOWING IS THE CODE IN MY MAIN method
static void Main(string [] args)

{

gArgs =args;

if(gArgs.Length > 0 && gArgs.Length == 2 )

{

//Invoked from Pocket Outlook


string menuOption = gArgs[0];

string oid = gArgs[1];

OutlookApplication app = new OutlookApplication();

switch(menuOption)

{

case "CALADDAPPT":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Activity to that
Account");

break;

case "CALUPDAPPT":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Activity as
Personal");

Appointment appt
=(Appointment)app.GetItemFromOid(Int32.Parse(oid),ItemType.Appointment);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Appointment,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "CONADDCON":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Contact to that Account");

break;

case "CONUPDCON":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Contact as Personal");

Contact con
=(Contact)app.GetItemFromOid(Int32.Parse(oid),ItemType.Contact );

//Check if the contact is present in DB

if(LookUPItem(ItemType.Contact ,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "TSKADDTSK":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Task to that Account");

break;

case "TSKUPDTSK":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Task as Personal");

Task tsk =(Task)app.GetItemFromOid(Int32.Parse(oid),ItemType.Task);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Task,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

}

}

Application.Run(new Form1());


}

TIA
Neelima
 
N

Neelima Godugu

Hi All,
Thanks for your valuable suggestions. I like the exe approach better. I will
try to go that path.
Thanks
Neelima
Peter Foot said:
One solution would be to create a launcher exe which checks if the program
is already running and if so negotiates with a MessageWindow in the .NETCF
application. Like Chris says - a pain in the ass.

Peter

--
Peter Foot
Windows Embedded MVP

www.inthehand.com | www.opennetcf.org

Chris Tacke said:
The problem is that the PocketPC is a pain in the ass and the CF enforces
that apps are singletons. It brings your current running app to the fore
and kills the new instance trying to start before Main is even run. CE
itself doesn't have this behavior, and I personally wish they left it to the
developer to enforce singleton apps for logo certification. With the method
they've implemented we can't get notifications for CeRunAppAtTime,
CeRunAppAtEvent and others.

--
Chris Tacke, eMVP
Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net

Neelima Godugu said:
Hi All,
I am trying to extend the menu's in PocketOutlook Calendar by using
CePimCommand funtion.
So far i have gotten to the point where I have been able to Launch my
CF
exe
when the Menu options are tapped.
The only problem I have is when my CF EXE is already running. In this case,
the App just comes into focus and the code that I included in the Main
method is not executed. Could anybody suggest a work around for this
problem.
Following is the CEPIMCOMMAND.DLL code
void CePimCommand(HWND hWnd,
PIMTYPE ptData,
UINT uDataCount,
HANDLE * rghData,
void * pReserved)
{

//Convert ceoid to string
CEOID hitem = ((CEOID)*rghData);
wchar_t strCEOID[40];
_itow(hitem,strCEOID,10);
//Modify TEXT(...) Appropriately
LPTSTR commandType = TEXT("TSKUPDTSK ");
wchar_t commandParams[100];
_tcscat(commandParams,commandType);
_tcscat(commandParams,strCEOID);

//Launch Dovarri
CreateProcess(TEXT("\\My
documents\\Dovarri\\dovarri.exe"),commandParams,NULL,
NULL,false,NULL,NULL,NULL,NULL,NULL);

}
//FOLLOWING IS THE CODE IN MY MAIN method
static void Main(string [] args)

{

gArgs =args;

if(gArgs.Length > 0 && gArgs.Length == 2 )

{

//Invoked from Pocket Outlook


string menuOption = gArgs[0];

string oid = gArgs[1];

OutlookApplication app = new OutlookApplication();

switch(menuOption)

{

case "CALADDAPPT":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Activity to that
Account");

break;

case "CALUPDAPPT":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Activity as
Personal");

Appointment appt
=(Appointment)app.GetItemFromOid(Int32.Parse(oid),ItemType.Appointment);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Appointment,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "CONADDCON":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Contact to that Account");

break;

case "CONUPDCON":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Contact as Personal");

Contact con
=(Contact)app.GetItemFromOid(Int32.Parse(oid),ItemType.Contact );

//Check if the contact is present in DB

if(LookUPItem(ItemType.Contact ,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

case "TSKADDTSK":

//Show a Dialog with an option to select the account

MessageBox.Show("Show Account List. Then Show Add Task to that Account");

break;

case "TSKUPDTSK":

//Retrieve

MessageBox.Show("UPD if already present otherwise Add Task as Personal");

Task tsk =(Task)app.GetItemFromOid(Int32.Parse(oid),ItemType.Task);

//Check if the appt is present in DB

if(LookUPItem(ItemType.Task,Int32.Parse(oid)))

{

//If found open the item in edit mode

}

else

{

//If not found add the item as personal item and open in edit mode

}



break;

}

}

Application.Run(new Form1());


}

TIA
Neelima
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top