QI to IOleWindow returns E_NOINTERFACE

V

Vinayakc

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
 
V

Vinayakc

Hi,

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

Regards,
Vinayakc
 
V

Vinayakc

Hi Dmitry,

Sorry for late repy. I could not access net for 3 days.
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
 
D

Dmitry Streblechenko

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
 
M

mwernerps2 via OfficeKB.com

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();
 
V

Vinayakc

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top