Microsoft KB Archive/888169

From BetaArchive Wiki
Knowledge Base


Article ID: 888169

Article Last Modified on 12/15/2004



APPLIES TO

  • Microsoft Windows CE 5.0
  • Microsoft Windows CE Platform Builder 4.2




SYMPTOMS

The Microsoft JScript onFocus event does not occur when the IESample browser window receives focus. This problem occurs when an HTML page uses the onFocus event in the document body.

CAUSE

This problem occurs because a bug exists in the sample source code for the IESample browser that is included with Microsoft Windows CE 5.0 and with Microsoft Windows CE Platform Builder 4.2.

WORKAROUND

To work around this problem, you must modify the sample source code for the IESample browser. To do this, follow these steps:

  1. Open the following source file:

    %WinCERoot%\Public\IE\Oak\IESample\Core\Mainwnd.cpp

  2. Locate the CMainWnd::BrowseWndProc function.
  3. Locate the WM_SETFOCUS message in the function that you located in step 2.
  4. Change case WM_SETFOCUS: to case WM_ACTIVATE:.
  5. The modified code will look similar to the following.

    LRESULT  CMainWnd::BrowseWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        CMainWnd *pMainWnd = this;
        if (pMainWnd)
        {
            switch (message)
            {
        ...
            //The following is the only modified line.
            case WM_ACTIVATE:           
                if (pMainWnd->_pIPActiveObj)
                {
                      pMainWnd->_pIPActiveObj->OnFrameWindowActivate(LOWORD(wParam) != WA_INACTIVE);
                }
                return 0;
        ...
        }
         }
    }
  6. Save the source file, and then rebuild the IESample application.


STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the problem

  1. Create a simple HTML document that calls the JScript onFocus handler from within the <body> tag as in the following example.

     <script language="JScript">
    function GotFocus() { alert("Got focus!"); }
    </script>
    <body onFocus="GotFocus();"> 
  2. Open the HTML document in the IESample browser. Notice that the onFocus event occurs when the document is first displayed.
  3. Open another window, such as Microsoft Windows Explorer, and then close it. Notice that the onFocus event does not occur when the focus switches back to the IESample browser window.


Keywords: kbbug KB888169