Pocket Internet Explorer Menu Is Overlaid on JScript Dialog Box (285534)



The information in this article applies to:

  • Microsoft Windows CE Operating System, Versions 3.0

This article was previously published under Q285534

SYMPTOMS

Microsoft Pocket Internet Explorer displays message boxes behind a menu if the message boxes are created by using JScript while the menu is active. Because the menu is on top and still has the focus, it is impossible to dismiss the message box. Additionally, the menu is inoperable; menu items can be highlighted, but not selected or activated.

Under these conditions, if you click Home, the Pocket Internet Explorer menu will remain on the screen. All other menus can opened and the menu items selected and activated, but when they close, the Pocket Internet Explorer menu remains.

CAUSE

The following sequence of events occur when this problem occurs:
  • The DialogBox function calls ReleaseCapture instead of sending a WM_CANCELMODE message.
  • When the pop-up menu receives the resulting WM_CAPTURECHANGED message, it calls ExitMenuLoop, which sets a flag to signal a subsequent message loop exit.
  • When WM_CAPTURECHANGED is returned, the dialog box handler enters its own message loop, so the menu does not have the opportunity to exit.
  • Because the menu still has the focus, the dialog box can not receive any keyboard input.

WORKAROUND

To resolve this problem, use one of the following methods:
  • Use two separate threads for the menu and message box.
  • Dismiss the menu before before calling MessageBox. You can do this as shown in the following sample code:
    case WM_TIMER:
          switch (wParam)
          {
             case 1:
                KillTimer(hWnd, 1);
                // 10 second timer to display message box
                SetTimer(hWnd, 2, 10000, NULL);
                hPopupMenu = CreatePopupMenu();
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 1"));
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 2"));
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 3"));
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 4"));
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 5"));
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 6"));
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 7"));
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 8"));
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 9"));
                AppendMenu(hPopupMenu, MF_ENABLED, 10000, TEXT("Choice 10"));
                TrackPopupMenu(hPopupMenu, TPM_NONOTIFY | TPM_TOPALIGN | TPM_LEFTALIGN, 200, 150, 0, hWnd, 0);
                break;
    
             case 2:
                KillTimer(hWnd, 2);
                // This will cause the pop-up menu to be dismissed.
                // PostMessage could also be used, but this way you are 
                // guaranteed that it willll definitely be dismissed 
                // before the message box is displayed.
                SendMessage(HWND_BROADCAST, WM_CANCELMODE, 0, 0L);
                // After the menu is dismissed, use PostMessage
                // to allow TrackPopupMenu() to return.
                PostMessage(hWnd, WM_APP, 0, 0L);
          }
          break;
       case WM_APP:
          // At this stage the menu has completely been destroyed.
          MessageBox(hWnd, TEXT("Text of the Message Box"), TEXT("Caption of the Message Box"), MB_OK);
          break;
    					

Modification Type:MinorLast Reviewed:5/27/2005
Keywords:kbnofix kbprb KB285534