PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Program Addins
QI to IOleWindow returns E_NOINTERFACE
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Program Addins
QI to IOleWindow returns E_NOINTERFACE
![]() |
QI to IOleWindow returns E_NOINTERFACE |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi all,
My add-in requires handle for Outlook main window. For that I have written one small piece of code as following. //*************************************************** CComPtr<IOleWindow> olOutlookWindow; result = m_pHostApp->ActiveExplorer(&pActiveExplorer); RET_IF_ERROR(L"ActiveExplorer", result) result = pActiveExplorer->QueryInterface(&olOutlookWindow); RET_IF_ERROR(L"GetWindowHandle",result); result = olOutlookWindow->GetWindow(&g_hOutlookWindow); RET_IF_ERROR(L"GetWindowHandle",result); //**************************************************** On my client's machine QueryInterface is failing with return code as E_NOINTERFACE. I don't know the configuration on client side. So it it is very difficult to trace this for me. Can someone please tell me what can be the possible causes of this problem and what is solution for this? Thanks and regards, Vinayakc |
|
|
|
#2 |
|
Guest
Posts: n/a
|
What is the Outlook version? When is that code called?
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Vinayakc" <vinayakchitre@gmail.com> wrote in message news:1144218953.744210.166570@g10g2000cwb.googlegroups.com... > Hi all, > > My add-in requires handle for Outlook main window. For that I have > written one small piece of code as following. > > //*************************************************** > CComPtr<IOleWindow> olOutlookWindow; > result = m_pHostApp->ActiveExplorer(&pActiveExplorer); > RET_IF_ERROR(L"ActiveExplorer", result) > > result = pActiveExplorer->QueryInterface(&olOutlookWindow); > RET_IF_ERROR(L"GetWindowHandle",result); > > result = olOutlookWindow->GetWindow(&g_hOutlookWindow); > RET_IF_ERROR(L"GetWindowHandle",result); > //**************************************************** > > On my client's machine QueryInterface is failing with return code as > E_NOINTERFACE. > I don't know the configuration on client side. So it it is very > difficult to trace this for me. > Can someone please tell me what can be the possible causes of this > problem and what is solution for this? > > Thanks and regards, > Vinayakc > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Hi,
Client is using Outlook 2003. This code is being called in OnStartupComplete() function. Regards, Vinayakc |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Can you try the code at some later time when Outlook is fully initialized?
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Vinayakc" <vinayakchitre@gmail.com> wrote in message news:1144297754.828450.179760@j33g2000cwa.googlegroups.com... > Hi, > > Client is using Outlook 2003. > This code is being called in OnStartupComplete() function. > > Regards, > Vinayakc > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Hi Dmitry,
Sorry for late repy. I could not access net for 3 days. >>Can you try the code at some later time when Outlook is fully initialized? No, I cant because this is happening on client side. On my machine it is working fine. So I can not test the fix even. Only thing I could not understand the possinbilities of this error. Thanks and Regards Vinayakc |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Any updates on this????
|
|
|
|
#7 |
|
Guest
Posts: n/a
|
No, since you are the only person who can access the machine where the
problem manifests itself. Why can't you move your code to a different event handler and see if that help? Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Vinayakc" <vinayakchitre@gmail.com> wrote in message news:1144913367.325310.133640@i40g2000cwc.googlegroups.com... > Any updates on this???? > |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Here is a solution that works. If the Outlook window cannot be found I get
the desktop window just to make sure it is 100% error free for getting a window handle. I just completed an application (www.intelligentconcepts.com) that I wrote this for then realized it was not needed for what I was trying to accomplish. I am interested why you want the Outlook window (maybe your using ATL and no MFC)? HWND hwndParent = NULL; try { IDispatch* pDispatch = NULL; if (g_pOutlookApp) { g_pOutlookApp->ActiveWindow(&pDispatch); if (pDispatch) { IOleWindow* pOleWindow; pDispatch->QueryInterface(IID_IOleWindow, (void **) &pOleWindow); if (pOleWindow) { pOleWindow->GetWindow(&hwndParent); pOleWindow->Release(); } } } } catch(...) { hwndParent = NULL; } if (!hwndParent) hwndParent = ::GetDesktopWindow(); -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums....addins/200604/1 |
|
|
|
#9 |
|
Guest
Posts: n/a
|
Hi,
Dmitry I moved my code to different event handler but it also doesn't work ![]() Meanwhile I used the above code to get the OL window. I am waiting for the feedback from the person on whose machine problem is ocurring. Thanks Vinayakc |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 


