Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1110449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:23:52+00:00 2026-05-17T02:23:52+00:00

In my application I have an embedded MSHTML control. The problem is that I

  • 0

In my application I have an embedded MSHTML control. The problem is that I cannot set focus to this control. I can click, select, push buttons etc, but it won’t accept keyboard input and mouse wheel notifications as a result. Even left-clicks on the control do not set the focus. (The question is related to this issue.)

Ultimately, I’ve tried 4 approaches. (Error handling is omitted here for brevity.) The first is sending WM_SETFOCUS to the control.

HWND iehwnd = ::FindWindowEx (m_oleObjectHWND, NULL, 
     L"Shell DocObject View", NULL);
if(iehwnd != NULL)
{
    iehwnd = ::FindWindowEx (iehwnd, NULL, L"Internet Explorer_Server", NULL);
    if(iehwnd != NULL)
    {
        ::PostMessage(iehwnd, WM_SETFOCUS, (WPARAM)GetHWND(), NULL);
    }
}

Using Winspector, I made sure that the messages came through to the control’s window, but it seems to ignore them.

The second is calling the focus() method of IHtmlWindow2.

    IHTMLDocument2* pHTMLDoc2 = NULL;
    m_webBrowser->get_Document((IDispatch**)&pHTMLDoc2);

    IHTMLWindow2* pWindow = 0;
    pHTMLDoc2->get_parentWindow(&pWindow);
    pWindow->focus();

This time, I get E_FAIL from focus().

MSDN says that the call may fail when the document hasn’t loaded, but pHTMLDoc2->get_readyState() returns “complete”. So this isn’t the case.

The third is doing the UIACTIVATE verb.

    hret = m_oleObject->DoVerb(OLEIVERB_UIACTIVATE, NULL, 
        clientSite, 0, (HWND)GetHWND(), &posRect);

This seems to achieve nothing.

The fourth is calling focus() of IHtmlDocument4.

    IDispatch* pdisp = NULL;
    m_webBrowser->get_Document((IDispatch**)&pdisp);

    IHTMLDocument4* pHTMLDoc4 = NULL;
    pdisp->QueryInterface(IID_IHTMLDocument4, (void**)(&pHTMLDoc4));

    pHTMLDoc4->focus();

Does nothing.

I’ve spent a full day on this already and know google’s links by heart now 🙂 Hoping for a hint from experts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:23:53+00:00Added an answer on May 17, 2026 at 2:23 am

    Finally found it.

    This function in my code (or rather the IEHtmlWin component for the wxWidgets library) returned S_FALSE. I changed the return code to S_OK – and voila…

    HRESULT FS_IOleInPlaceSiteWindowless::RequestUIActivate()
    {
    return S_OK;
    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MSHTML-based control embedded in an application and the ContentEditable mode is
I have an application that sends an HTML formatted email with embedded images. The
I have an application on the Compact Framework that has some large embedded resources
Currently, I have an application that uses Firebird in embedded mode to connect to
I have a spring application that uses an embedded Jetty instance. Since I am
I have embedded some crystal reports in my C# application. The problem is, compiling
Inside of my WPF application, I have embedded a WebBrowser control, which in turn
I have an embedded scripting engine in my C# application that uses IronPython 2.
I have the following requirement: I have created a Flash application that is embedded
How does one compares to the other? I have an embedded application that if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.