Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: QI to IOleWindow returns E_NOINTERFACE

Geek News

QI to IOleWindow returns E_NOINTERFACE
"Vinayakc" <vinayakchitre[ at ]gmail.com> 4/5/2006 6:35:53 AM
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

Re: QI to IOleWindow returns E_NOINTERFACE
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 4/5/2006 6:29:54 PM
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[ at ]gmail.com> wrote in message
news:1144218953.744210.166570[ at ]g10g2000cwb.googlegroups.com...
[Quoted Text]
> 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
>


Re: QI to IOleWindow returns E_NOINTERFACE
"Vinayakc" <vinayakchitre[ at ]gmail.com> 4/6/2006 4:29:14 AM
Hi,

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

Regards,
Vinayakc

Re: QI to IOleWindow returns E_NOINTERFACE
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 4/6/2006 5:00:25 PM
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[ at ]gmail.com> wrote in message
news:1144297754.828450.179760[ at ]j33g2000cwa.googlegroups.com...
[Quoted Text]
> Hi,
>
> Client is using Outlook 2003.
> This code is being called in OnStartupComplete() function.
>
> Regards,
> Vinayakc
>


Re: QI to IOleWindow returns E_NOINTERFACE
"Vinayakc" <vinayakchitre[ at ]gmail.com> 4/11/2006 6:59:38 AM
Hi Dmitry,

Sorry for late repy. I could not access net for 3 days.

[Quoted Text]
>>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

Re: QI to IOleWindow returns E_NOINTERFACE
"Vinayakc" <vinayakchitre[ at ]gmail.com> 4/13/2006 7:29:27 AM
Any updates on this????

Re: QI to IOleWindow returns E_NOINTERFACE
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 4/13/2006 4:59:20 PM
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[ at ]gmail.com> wrote in message
news:1144913367.325310.133640[ at ]i40g2000cwc.googlegroups.com...
[Quoted Text]
> Any updates on this????
>


Re: QI to IOleWindow returns E_NOINTERFACE
"mwernerps2 via OfficeKB.com" <u10791[ at ]uwe> 4/14/2006 5:34:30 AM
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.aspx/outlook-prog-addins/200604/1
Re: QI to IOleWindow returns E_NOINTERFACE
"Vinayakc" <vinayakchitre[ at ]gmail.com> 4/28/2006 6:51:34 AM
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

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net