I have a Cab project which extends contact's contextmenu items.
But When I installed the same cab file on smartphone it installed successfully but contextmenu items remains same
Could there be any change in the installation file.
this is my ini file to built the cab file
[Version]
Signature = "$Windows NT$"
Provider = "MyProject"
CESignature = "$Windows CE$"
[CEStrings]
AppName = "MyWireless"
InstallDir = %CE1%\%AppName%
[Strings]
NOW_PPC_Dir = D:\Projects\MyOffice\OriginalPocketPC\WM5\NOW_PPC
LIBS_DIR = D:\Projects\MyOffice\OriginalPocketPC\WM5\libs\"
[CEDevice]
UnsupportedPlatforms = "HPC","Jupiter","Palm PC2"
VersionMin = 3.0
VersionMax = 10.0
[CEDevice.PPC2003_ARM]
ProcessorType = 2577
[CEDevice.PPC2003_x86]
ProcessorType = 686
[SourceDisksNames]
11=,"Common5",,%LIBS_DIR%
12=,"Common3",,"D:\Projects\MyOffice\OriginalPocketPC\WM5\NOW_PPC\ctxmenu\Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\Debug\"
[SourceDisksFiles]
System.SR.dll = 11
"nowmenu.dll" = 12
[DefaultInstall]
CopyFiles = Files.Windows,Files.InstallDir
CESelfRegister = nowmenu.dll
CESelfRegister = System.SR.dll
[DestinationDirs]
Files.Windows = 0,%CE2%
Files.InstallDir = 0,%InstallDir%
[Files.InstallDir]
System.SR.dll
[Files.Windows]
nowmenu.dll
[Shortcuts]
MYWireless,0,AppLauncher.exe,%CE11%

Extending Context menu for Windows mobile 5.0 Samrtphone Contacts
Marcin Książek
Santiagon
LittleSettler
Please, review CallingCard sample carefully. For example here is your QueryContextMenu implementation:
tamorgen
This is my class
class CContextMenuSample : public IContextMenu, IObjectWithSite
{
public:
// constructors
CContextMenuSample();
// destructor
~CContextMenuSample();
// IUnknown methods
STDMETHOD (QueryInterface) (REFIID riid, LPVOID *ppv);
STDMETHOD_(ULONG, AddRef) (void);
STDMETHOD_(ULONG, Release) (void);
// IContextMenu methods
STDMETHOD (GetCommandString) (UINT idCmd, UINT uFlags, UINT *pwReserved,
LPSTR pszName, UINT cchMax);
STDMETHOD (InvokeCommand) (LPCMINVOKECOMMANDINFO pici);
STDMETHOD (QueryContextMenu) (HMENU hmenu, UINT indexMenu, UINT idCmdFirst,
UINT idCmdLast, UINT uFlags);
// IObjectWithSite methods
STDMETHOD (GetSite) (REFIID riid, void **ppvSite);
STDMETHOD (SetSite) (IUnknown *pUnkSite);
// CContextMenuSample methods
// None
protected:
ULONG m_cRef; // reference count
IUnknown *m_punkSite; // site (owner) pointer
};
Also I can't find any sample of IContextMenu::QueryContextMenu() for contact
And where I have to implement it
And following is my ContactsContextmenu class
#include "common.h"
#include "appext.h"
#include "ContactsExtDBProvider.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()
{
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 WinCE
hr = 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
)
{
// MessageBox(NULL, 0, TEXT("CME Sample"), MB_OK);
HRESULT hr = NOERROR;
/* if (menuCreated)
{
//InsertMenu(hmenu, cmdAdd, MF_BYCOMMAND | MF_SEPARATOR, cmdCustom, NULL);
// InsertMenu(hmenu, cmdFax, MF_BYPOSITION | MF_SEPARATOR, cmdCustom, NULL);
// return hr;
DeleteMenu(hmenu, MF_BYCOMMAND, cmdCustom);
DeleteMenu(hmenu, MF_BYCOMMAND, cmdJournal);
DeleteMenu(hmenu, MF_BYCOMMAND, cmdSales);
DeleteMenu(hmenu, MF_BYCOMMAND, cmdFax);
DeleteMenu(hmenu, MF_BYCOMMAND, cmdAdd);
DeleteMenu(hmenu, MF_BYCOMMAND, ++cmdAdd);
DeleteMenu(hmenu, MF_BYCOMMAND, ++cmdAdd);
// menuCreated = false;
}
*/
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("Custom fields...");
TCHAR szCommand2[MAX_PATH] = TEXT("Journal...");
TCHAR szCommand3[MAX_PATH] = TEXT("Sales...");
TCHAR szCommand4[MAX_PATH] = TEXT("Fax/Email document...");
TCHAR szCommand5[MAX_PATH] = TEXT("Edit additional info...");
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 interface
hr = 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;
}
tirengarfio
Could any body give me a smaple for Extending Context menu for Windows mobile 5.0 Samrtphone Contacts.
I want's the example for Contacts in particular.
I want's to use IContextMenu example instead of CePimCommand
fubnuts
Thanks Alex
I just want a sample for adding a new item for contact's context menu.
Appel
Sorry, but this forum is for questions related to the DeviceEmulator. I'll move it to the managed programming forum.
Barry
ChangLuo
You can find a sample in the Windows Mobile 5.0 Smartphone SDK.
They are located in these directories
.\Windows Mobile 5.0 Smartphone SDK\Samples\CPP\Win32\Callingcard
.\Windows Mobile 5.0 Smartphone SDK\Samples\CPP\Win32\Inboxmenuextensibility\InboxMenuExtensibility
MauriceSibrandi
I suggest that you build your project for Smartphone - the INF file suggest it has been built for PPC. Also this part is highly questionable:
CESelfRegister = System.SR.dll
The most likely reason you don't see the menu extension is that your module is not signed. Test it on the emulator and turn the code signing on in the project properties. See if that helps
ruckazz
I have seen it but it is not exactly what i want's[i.e. for contact]
Calling card is a bit like that but not exact.
I simply want's to add a menu item in the contact right
On which If i click I want's to open a new application.
How can I do that
I can't find any sample QueryContextMenu() in my scenario
Please help
Erick-Flores
elgor
c_shah
Yes I am able to see that following is my CEPimcommand implementation how can I convert it
void CePimCommand (HWND hWnd, PIMTYPE ptData, UINT uDataCount,
HANDLE *rghData, void *pReserved)
{
if (uDataCount > 0)
{
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.hInstance = g_hInst;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszClassName = DummyWindow1;
RegisterClass(&wc);
if(!CreateWindow(DummyWindow1, DummyWindow1, 0,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, g_hInst, NULL))
{
}
else
{
HWND wnd = FindWindow(DummyWindow, DummyWindow);
SendMessage(wnd, WM_TEST, 0, 0);
PostMessage(hNetClient, WM_EDIT_CONTACT_EXT, (CEOID) *rghData, 0);
}
}
}
Atlantaazfinest
Smartphone 5 SDK contains 3 samples - Samples\Win32\CallingCard, Samples\Win32\InboxMenuExtensibility and Samples\Win32\ReadViewMenuExt