Bonjour,
Développant une application que je porte pour Windows Mail sur le nouveau Vista, j'ai un soucis avec l'appel de cette fonction (que je n'avais pas sous les autres OS Windows et Outlook Express!) :
=> hr = m_pFolder->RegisterNotification( 0, m_pOENotifyWnd->m_hWnd );
Elle n'abouti pas et me renvoi une erreur COM (
-2147467263 ) non indiqué sur la MSDN http://msdn2.microsoft.com/en-us/library/ms710256.aspx
Voici les deux classes nécessaires a la compréhension du fonctionnement :
class COEFolderWrapper
{
public:
COEFolderWrapper():
m_pFolder(NULL),
m_pOENotifyWnd(NULL)
{
}
~COEFolderWrapper()
{
if( m_pOENotifyWnd )
{
m_pOENotifyWnd->DestroyWindow();
delete m_pOENotifyWnd;
m_pOENotifyWnd = NULL;
}
}
}
//
// SetFolder
//
/////////////////////////////////////////////////////////////////////////
VOID SetFolder(CComPtr<IStoreFolder> pFolder)
{
HRESULT hr = S_OK;
m_pFolder = pFolder;
if( m_pFolder )
{
m_pFolder->AddRef();
CRect rect(10, 10, 100, 100);
m_pOENotifyWnd = new(COENotifyWnd);
if( m_pOENotifyWnd->CreateEx( NULL,
AfxRegisterWndClass(0,0,0,0),_T("OENotifyWnd"),WS_POPUP,rect, NULL,
NULL, NULL ))
{
m_pOENotifyWnd->SetFolder( m_pFolder );
hr = m_pFolder->RegisterNotification( 0, m_pOENotifyWnd->m_hWnd );
//#ifdef IS_TEST
FOLDERPROPS props;
props.cbSize = sizeof(FOLDERPROPS);
m_pFolder->GetFolderProps( 0, &props );
if( hr == E_INVALIDARG )
{
MessageBox( NULL, props.szName, "E_INVALIDARG : COEFolderWrapper::SetFolder", MB_OK );
}
if( hr == E_FAIL )
{
MessageBox( NULL, props.szName, "E_FAIL : COEFolderWrapper::SetFolder", MB_OK );
}
if( hr != S_OK )
{
CString str;
str.Format("%d",hr);
MessageBox( NULL, str, "S_OK : COEFolderWrapper::SetFolder", MB_OK );
MessageBox( NULL, props.szName, "S_OK : COEFolderWrapper::SetFolder", MB_OK );
}
if( hr == S_OK )
{
CString str;
str.Format("%d",hr);
MessageBox( NULL, str, "S_OK : COEFolderWrapper::SetFolder", MB_OK );
MessageBox( NULL, props.szName, "ISGOOD : COEFolderWrapper::SetFolder", MB_OK );
}
//#endif
}
else
MessageBox( NULL, "BAD", "BAD", MB_OK );
}
}
//
// Unregister
//
/////////////////////////////////////////////////////////////////////////
VOID Unregister()
{
if( m_pFolder )
{
m_pFolder->UnregisterNotification( 0, m_pOENotifyWnd->m_hWnd );
m_pFolder->Release();
m_pFolder = NULL;
}
}
IStoreFolder* m_pFolder;
COENotifyWnd* m_pOENotifyWnd;
};
// COENotifyWnd dialog used for App About
class COENotifyWnd : public CWnd
{
public:
COENotifyWnd();
// Dialog Data
//enum { IDD = IDD_OENOTIFYWND };
//VOID SetRes(HMODULE hResModule){ AfxGetResourceHandle() = hResModule; }
public:
afx_msg LRESULT OnNewMsgs(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnFolderNotify(WPARAM wParam, LPARAM lParam);
VOID SetFolder(IStoreFolder* pFolder){ m_pFolder = pFolder; }
IStoreFolder* m_pFolder;
protected:
//HMODULE AfxGetResourceHandle();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//virtual BOOL OnInitDialog();
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
COENotifyWnd::COENotifyWnd()// : CDialog(COENotifyWnd::IDD)
{
}
void COENotifyWnd::DoDataExchange(CDataExchange* pDX)
{
CWnd::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(COENotifyWnd, CWnd)
ON_MESSAGE(WM_NEWMSGS,COENotifyWnd::OnNewMsgs)
ON_MESSAGE(WM_FOLDERNOTIFY,COENotifyWnd::OnFolderNotify)
END_MESSAGE_MAP()
//
// OnNewMsgs
//
/////////////////////////////////////////////////////////////////////////
LRESULT COENotifyWnd::OnNewMsgs(WPARAM wParam, LPARAM lParam)
{ MessageBox("OnNewMsgs","OnNewMsgs",MB_OK);
#ifdef IS_MANAGEMUTLFOLDERS_OE
OEPlugin_OnNewMsgs( wParam, lParam, m_pFolder );
#else
OEPlugin_OnNewMsgs( wParam, lParam );
#endif
return 0;
}
//
// OnFolderNotify
//
/////////////////////////////////////////////////////////////////////////
LRESULT COENotifyWnd::OnFolderNotify(WPARAM wParam, LPARAM lParam)
{
OEPlugin_OnFolderNotify( wParam, lParam );
return 0;
}
L'appel à cette fonction est essentiel à mon application car sinon, mon appli ne pourra pas être notifié des évenements survenant dans les dossiers de windows mail à surveiller par celle-ci.
Ainsi, je recherche de l'aide ou des voix a suivre pour y arriver, car là je séche depuis plusieurs jours!
Merci par avance!