#include
"common.h"#include
"MYappext.h"#include
"MYContactsProvider.h"
extern
LONG g_cRefDLL;extern
HINSTANCE g_hinstDLL;
UINT cmdCtxCustom = 0;
UINT cmdCtxJournal = 0;
UINT cmdCtxSales = 0;
UINT cmdCtxFax = 0;
UINT cmdCtxAdd = 0;
UINT curCtxCmd = 0;
const
int WM_CUSTOM_FLDS = 0x0415;const
int WM_JOURNAL_FLDS = 0x0416;const
int WM_SHOW_SALES = 0x0407;const
int WM_FAX = 0x0431;const
int WM_EDIT_CONTACT_EXT = 0x0408;
ContactsContextMenu::ContactsContextMenu()
{
MessageBox(0, L
" ContactsContextMenu ", L" Constructor ", 0);m_cRef = 0;
m_punkSite = NULL;
++g_cRefDLL;
}
ContactsContextMenu::~ContactsContextMenu()
{
ASSERT(0 == m_cRef);
if (NULL != m_punkSite)m_punkSite->Release();
--g_cRefDLL;
}
STDMETHODIMP_(ULONG) ContactsContextMenu::AddRef()
{
return (ULONG)InterlockedIncrement(&m_cRef);}
STDMETHODIMP_(ULONG) ContactsContextMenu::Release()
{
ULONG cnt = (ULONG)InterlockedDecrement((LPLONG)&m_cRef);
if(0!=cnt) return(cnt); //delete this; return(0);}
STDMETHODIMP ContactsContextMenu::QueryInterface(
REFIID riid,
LPVOID *ppv
)
{
if (NULL == ppv) return E_POINTER;*ppv = NULL;
if (IID_IUnknown == riid)*ppv = (LPVOID)
this; else if (IID_IContextMenu == riid)*ppv =
dynamic_cast<IContextMenu*>(this); else if (IID_IObjectWithSite == riid)*ppv =
dynamic_cast<IObjectWithSite*>(this); if (NULL != *ppv){
((IUnknown *)(*ppv))->AddRef();
return S_OK;}
return E_NOINTERFACE;}
STDMETHODIMP ContactsContextMenu::GetCommandString(
UINT idCmd,
UINT uFlags,
UINT *pwReserved,
LPSTR pszName,
UINT cchMax
)
{
curCtxCmd = idCmd;
return NOERROR;}
STDMETHODIMP ContactsContextMenu::InvokeCommand(
LPCMINVOKECOMMANDINFO pici
)
{
HRESULT hr = NOERROR;
if (NULL == pici){
hr = E_POINTER;
}
else{
if (sizeof(CMINVOKECOMMANDINFO) != pici->cbSize){
// there's no CMINVOKECOMMANDINFOEX in WinCEhr = E_INVALIDARG;
}
else{
IDataObject *pIdo;
if (FAILED(GetSite(IID_IDataObject, (void **)&pIdo))){
hr = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL,
ERROR_NO_SUCH_SITE);
}
else{
FORMATETC fe={0};
STGMEDIUM sm;
fe.cfFormat = RegisterClipboardFormat(CFNAME_ITEMREFARRAY);
fe.lindex = -1;
fe.dwAspect = DVASPECT_CONTENT;
fe.tymed = TYMED_HGLOBAL;
ItemRefArray *pira;
CEOID oid=0;
HRESULT hr = pIdo->GetData(&fe, &sm);
if (!FAILED(hr)) {pira = (ItemRefArray*)sm.hGlobal;
oid = (CEOID)pira->rgRefs[0].pRef;
}
pIdo->Release();
if (!FAILED(hr)){
if (curCtxCmd == cmdCtxCustom){
MsgSender::Send(WM_CUSTOM_FLDS, oid);
}
else if (curCtxCmd == cmdCtxJournal){
MsgSender::Send(WM_JOURNAL_FLDS, oid);
}
else if (curCtxCmd == cmdCtxSales){
MsgSender::Send(WM_SHOW_SALES, oid);
}
else if (curCtxCmd == cmdCtxFax){
MsgSender::Send(WM_FAX, oid);
}
else if (curCtxCmd == cmdCtxAdd){
MsgSender::Send(WM_EDIT_CONTACT_EXT, oid);
}
}
}
}
}
return hr;}
STDMETHODIMP ContactsContextMenu::QueryContextMenu(
HMENU hmenu,
UINT indexMenu,
UINT idCmdFirst,
UINT idCmdLast,
UINT uFlags
)
{
HRESULT hr = NOERROR;
UNREFERENCED_PARAMETER(uFlags);
if (idCmdLast < idCmdFirst){
hr = E_INVALIDARG;
}
else{
IDataObject *pIdo;
// get the site if (FAILED(GetSite(IID_IDataObject, (void **)&pIdo))){
hr = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL,
ERROR_NO_SUCH_SITE);
}
else{
FORMATETC fe={0};
STGMEDIUM sm;
fe.cfFormat = RegisterClipboardFormat(CFNAME_ITEMREFARRAY);
fe.lindex = -1;
fe.dwAspect = DVASPECT_CONTENT;
fe.tymed = TYMED_HGLOBAL;
ItemRefArray *pira;
int existFlag = MF_GRAYED;hr = pIdo->GetData(&fe, &sm);
if (!FAILED(hr)) {CEOID oid;
pira = (ItemRefArray*)sm.hGlobal;
oid = (CEOID)pira->rgRefs[0].pRef;
ContactsExtDBProvider* dbContactsExt =
new ContactsExtDBProvider(); if (!dbContactsExt->IsExist())dbContactsExt->CreateDB();
if (!(dbContactsExt->FindItem(oid) <= 0))existFlag = MF_ENABLED;
}
ReleaseStgMedium(&sm);
pIdo->Release();
TCHAR szCommand1[MAX_PATH] = TEXT(
"AA...");TCHAR szCommand2[MAX_PATH] = TEXT(
"BB...");TCHAR szCommand3[MAX_PATH] = TEXT(
"CC...");TCHAR szCommand4[MAX_PATH] = TEXT(
"DD...");TCHAR szCommand5[MAX_PATH] = TEXT(
"FF...");cmdCtxCustom = idCmdFirst;
cmdCtxJournal = idCmdFirst + 1;
cmdCtxSales = idCmdFirst + 3;
cmdCtxFax = idCmdFirst + 4;
cmdCtxAdd = idCmdFirst + 5;
if (InsertMenu(hmenu, 0xFFFFFFFF, MF_BYPOSITION | MF_SEPARATOR, idCmdFirst + 2, NULL) &&InsertMenu(hmenu, 0xFFFFFFFF, MF_BYPOSITION | existFlag, cmdCtxCustom, szCommand1) &&
InsertMenu(hmenu, 0xFFFFFFFF, MF_BYPOSITION | existFlag, cmdCtxJournal, szCommand2) &&
InsertMenu(hmenu, 0xFFFFFFFF, MF_BYPOSITION | existFlag, cmdCtxSales, szCommand3) &&
InsertMenu(hmenu, 0xFFFFFFFF, MF_BYPOSITION | existFlag, cmdCtxFax, szCommand4) &&
// InsertMenu(hmenu, 0xFFFFFFFF, MF_BYPOSITION | MF_SEPARATOR, ++idCmdLast, NULL) &&
InsertMenu(hmenu, 0xFFFFFFFF, MF_BYPOSITION | existFlag, cmdCtxAdd, szCommand5))
{
// InsertMenu(hmenu, 2, MF_BYPOSITION | MF_SEPARATOR, idCmdFirst + 2, NULL);
// InsertMenu(hmenu, 2 + 5, MF_BYPOSITION | MF_SEPARATOR, idCmdFirst + 6, NULL);
//hr = MAKE_HRESULT(SEVERITY_SUCCESS, 0, 7);
// menuCreated = true;
}
}
}
return hr;}
STDMETHODIMP ContactsContextMenu::GetSite(
REFIID riid,
void **ppvSite)
{
HRESULT hr = NOERROR;
if (NULL == ppvSite){
hr = E_POINTER;
}
else{
if (NULL == m_punkSite){
// no site*ppvSite = NULL;
hr = E_FAIL;
}
else{
// see if we have the requested interfacehr = m_punkSite->QueryInterface(riid, ppvSite);
}
}
return hr;}
STDMETHODIMP ContactsContextMenu::SetSite(
IUnknown *pUnkSite
)
{
if (NULL != pUnkSite){
pUnkSite->AddRef();
}
if (NULL != m_punkSite){
m_punkSite->Release();
}
m_punkSite = pUnkSite;
return NOERROR;}

What wrong in this code for smartphone work well in pocket PC
AlucardHellSing
cwlaualex
How are you clicking "Contact" in Smart phone As previously said, PPC and SP have different UI models. PPC supports tap i.e. click whereas SP don't.
Manav
Frosto
I have put a message in my main class method of
DllGetClassObject
Now when I run it in pocket pc it appears when i click contact but when I run it in smartphone nothing happen
Any idea
Mike Barry
JasonG271009
How are you invoking this Smartphones don't have support for "tapping" i.e. no mouse input if testing on emulator. You have to use keys to navigate so you may have to write a separate event handler. Debug and see if you're catching the event that gets fired in Smart Phone
Manav
MohsinAta
This is the definition i have in DllGetClassObject
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID FAR* ppvOut)
{
MessageBox(0, L
" DllGetClassObject ", L" I am in DllGetClassObject ", 0); if (NULL == ppvOut) return E_INVALIDARG;*ppvOut = NULL;
HRESULT hr = S_OK;
if (IsEqualIID(rclsid, CLSID_ContactsToolsMenu)){
ContactsToolsMenuFactory *pcf =
new ContactsToolsMenuFactory;hr = pcf->QueryInterface(riid, ppvOut);
if (pcf != NULL) pcf->Release();}
else if (IsEqualIID(rclsid, CLSID_ContactsSummaryToolsMenu)){
ContactsSummaryToolsMenuFactory *pcf =
new ContactsSummaryToolsMenuFactory;hr = pcf->QueryInterface(riid, ppvOut);
if (pcf != NULL) pcf->Release();}
else if (IsEqualIID(rclsid, CLSID_ContactsContextMenu)){
ContactsContextMenuFactory *pcf =
new ContactsContextMenuFactory;hr = pcf->QueryInterface(riid, ppvOut);
if (pcf != NULL) pcf->Release();}
elsehr = CLASS_E_CLASSNOTAVAILABLE;
return (hr);}
the message appears when I click contact in pocket pc but not in smartphone
Tim Dallmann
BerW
Please submit a specific question about the problem you're facing. You've to do the hard work of identifying the problem area and others will help you out solve it.
Manav
x0ras
Problem is in this class.
I have put an message in the constructor of this classs.
When I run it in pocket pc i see the message when I click contact menu
But there isn't any thing happen when I run same in smart phone.
Could any body give me the reason
Mike_Sos
I am clciking tool menu[or you can say right soft key ]
What can I do