Microsoft KB Archive/75254

{|
 * width="100%"|

PRB: TrackPopupMenu on LoadMenuIndirect Menu Causes UAE

 * }

Q75254

-

The information in this article applies to:


 * Microsoft Windows Software Development Kit (SDK)
 * Microsoft Win32 Software Development Kit (SDK), used with:
 * Microsoft Windows 95
 * the operating system: Microsoft Windows NT, versions 3.5, 3.51
 * the operating system: Microsoft Windows 2000

-

SYMPTOMS
When LoadMenuIndirect is used to create a menu from a menu template and the menu handle is passed to TrackPopupMenu, Windows reports an unrecoverable application error (UAE). Windows NT and Windows 95 display the floating pop-up menu as a vertical bar.

CAUSE
The menu handle returned from LoadMenuIndirect does not point to a menu with the MF_POPUP bit set.

RESOLUTION
The following code fragment demonstrates the correct procedure to &quot;wrap&quot; the menu created by LoadMenuIndirect inside another menu. This procedure sets the MF_POPUP bit properly.

  hMenu1 = LoadMenuIndirect(lpMenuTemplate);

hMenuDummy = CreateMenu; InsertMenu(hMenuDummy, 0, MF_POPUP, hMenu1, NULL);

hMenuToUse = GetSubMenu(hMenuDummy, 0); Use hMenuToUse when TrackPopupMenu is called. The values of hMenu1 and hMenuToUse should be the same.

When the menu is no longer required, call DestroyMenu to remove hMenuDummy. This call will also destroy hMenu1 and free the resources it used.

Additional query words:

Keywords : _IK kbMenu kbOSWinNT350 kbOSWinNT351 kbOSWin2000 kbResource kbSDKWin32 kbGrpDSUser kbOSWin kbOSWin95

Issue type : kbprb

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch kbWinSDKSearch