Inside the WinCE GUI
By Meiyu Lin, November 01, 2001
A small user interface can sometimes present big challenges. From menu bars and property sheets to extending Pocket Outlook, Meiyu presents several tips to bring those tasks down to size.
November 2001/Inside the WinCE GUI/Listing 1
Listing 1: connectPoom.cpp
Using the Pocket Outlook Object Model
// To Use Pocket OutLook Make sure the pimstore.dll is
// on the device, and create the instance for IID_IPOutlookApp
#define POA_OBJECT _T("PocketOutlook.Application")
#define YOURAPP_REG_KEY
_T("Software\\Microsoft\\PimApps\\PimExtensions\\Contacts\\AddIns\\YourApps")
// In resource file you will need to define the following:
#define IDS_MSCONTACT_MENU 400
STRINGTABLE DISCARDABLE
BEGIN
IDS_MSCONTACT_MENU "Call Contact" // The string will appear on
// the tools and popup menu
END
BOOL ConnectToPocketOutLook (void)
{
CLSID clsid;
HRESULT hr;
HRFUNC pProc;
// Start by initializing COM
CoInitializeEx (NULL, 0);
// Get the CLSID for the application
hr = CLSIDFromProgID (POA_OBJECT, &clsid);
if (FAILED(hr))
{
//example: DebugPrint (_T("ClassName::method Name"),
// _T("%d,\t%s"), GetLastError(), tcbuffer);
g_hPimstore = LoadLibrary (TEXT("\\windows\\pimstore.dll"));
if (!g_hPimstore)
{
// You gotta have pimstore.dll, dude
return FALSE;
}
pProc = (HRFUNC) GetProcAddress(g_hPimstore, TEXT("DllRegisterServer"));
if (!pProc)
{
return FALSE;
}
// Register, please
pProc();
hr = CLSIDFromProgID(POA_OBJECT, &clsid);
if (FAILED(hr))
{
return FALSE;
}
}
// Now, let's get the main application
hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
IID_IPOutlookApp, (PPVOID) &g_polApp);
if (FAILED(hr))
{
return FALSE;
}
return TRUE;
}
// To dial from poom contact, first we need to create the registry key and
// add a menu to contact for dialing directly from Contacts
BOOL CreatePoomDialerRegistry ()
{
HKEY hKey;
TCHAR tcMenu[MAX_PATH+1] = _T("\0");
BOOL bReturn = FALSE;
if (ERROR_SUCCESS == RegCreateKeyEx (HKLM, YOURAPP_REG_KEY, 0, NULL, 0,
KEY_ALL_ACCESS, NULL, &hKey, NULL))
{
LPTSTR ptcData = _T("YourPoom.dll");
LoadString (IDS_MSCONTACT_MENU, tcMenu, MAX_PATH);
// lpValueName: the name of the value to set.
// lpData: [in] Pointer to a buffer containing the data to be stored
// with the specified value name.
RegSetValueEx( hKey, _T("DLL"), NULL, REG_SZ, (BYTE*)ptcData,
(_tcslen(ptcData)+1)*sizeof (TCHAR));
RegSetValueEx( hKey, _T("MENU"), NULL, REG_SZ, (BYTE*)tcMenu,
(_tcslen(tcMenu)+1)*sizeof (TCHAR));
RegCloseKey( hKey );
bReturn = TRUE;
}
return bReturn;
}
//End of File