PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Program Addins QI to IOleWindow returns E_NOINTERFACE

Reply

QI to IOleWindow returns E_NOINTERFACE

 
Thread Tools Rate Thread
Old 05-04-2006, 07:35 AM   #1
Vinayakc
Guest
 
Posts: n/a
Default QI to IOleWindow returns E_NOINTERFACE


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

  Reply With Quote
Old 05-04-2006, 07:29 PM   #2
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: QI to IOleWindow returns E_NOINTERFACE

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
>



  Reply With Quote
Old 06-04-2006, 05:29 AM   #3
Vinayakc
Guest
 
Posts: n/a
Default Re: QI to IOleWindow returns E_NOINTERFACE

Hi,

Client is using Outlook 2003.
This code is being called in OnStartupComplete() function.

Regards,
Vinayakc

  Reply With Quote
Old 06-04-2006, 06:00 PM   #4
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: QI to IOleWindow returns E_NOINTERFACE

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
>



  Reply With Quote
Old 11-04-2006, 07:59 AM   #5
Vinayakc
Guest
 
Posts: n/a
Default Re: QI to IOleWindow returns E_NOINTERFACE

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

  Reply With Quote
Old 13-04-2006, 08:29 AM   #6
Vinayakc
Guest
 
Posts: n/a
Default Re: QI to IOleWindow returns E_NOINTERFACE

Any updates on this????

  Reply With Quote
Old 13-04-2006, 05:59 PM   #7
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: QI to IOleWindow returns E_NOINTERFACE

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????
>



  Reply With Quote
Old 14-04-2006, 06:34 AM   #8
mwernerps2 via OfficeKB.com
Guest
 
Posts: n/a
Default Re: QI to IOleWindow returns E_NOINTERFACE

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
  Reply With Quote
Old 28-04-2006, 07:51 AM   #9
Vinayakc
Guest
 
Posts: n/a
Default Re: QI to IOleWindow returns E_NOINTERFACE

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

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off