+int
+popup_activated ()
+{
+ /* popup_activated_flag not actually used on W32 */
+ return 0;
+}
+
+/* Display help string for currently pointed to menu item. Not
+ supported on NT 3.51 and earlier, as GetMenuItemInfo is not
+ available. */
+void
+w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags)
+{
+ if (get_menu_item_info)
+ {
+ struct frame *f = x_window_to_frame (&one_w32_display_info, owner);
+ Lisp_Object frame, help;
+
+ // No help echo on owner-draw menu items.
+ if (flags & MF_OWNERDRAW || flags & MF_POPUP)
+ help = Qnil;
+ else
+ {
+ MENUITEMINFO info;
+
+ bzero (&info, sizeof (info));
+ info.cbSize = sizeof (info);
+ info.fMask = MIIM_DATA;
+ get_menu_item_info (menu, item, FALSE, &info);
+
+ help = info.dwItemData ? (Lisp_Object) info.dwItemData : Qnil;
+ }
+
+ /* Store the help echo in the keyboard buffer as the X toolkit
+ version does, rather than directly showing it. This seems to
+ solve the GC problems that were present when we based the
+ Windows code on the non-toolkit version. */
+ if (f)
+ {
+ XSETFRAME (frame, f);
+ kbd_buffer_store_help_event (frame, help);
+ }
+ else
+ /* X version has a loop through frames here, which doesn't
+ appear to do anything, unless it has some side effect. */
+ show_help_echo (help, Qnil, Qnil, Qnil, 1);
+ }
+}
+
+/* Free memory used by owner-drawn strings. */
+static void
+w32_free_submenu_strings (menu)
+ HMENU menu;
+{
+ int i, num = GetMenuItemCount (menu);
+ for (i = 0; i < num; i++)
+ {
+ MENUITEMINFO info;
+ bzero (&info, sizeof (info));
+ info.cbSize = sizeof (info);
+ info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_SUBMENU;
+
+ get_menu_item_info (menu, i, TRUE, &info);
+
+ /* Owner-drawn names are held in dwItemData. */
+ if ((info.fType & MF_OWNERDRAW) && info.dwItemData)
+ {
+#ifdef MENU_DEBUG
+ DebPrint ("Menu: freeing %ld for owner-draw", info.dwItemData);
+#endif
+ local_free (info.dwItemData);
+ }
+
+ /* Recurse down submenus. */
+ if (info.hSubMenu)
+ w32_free_submenu_strings (info.hSubMenu);
+ }
+}
+
+void
+w32_free_menu_strings (hwnd)
+ HWND hwnd;
+{
+ HMENU menu = current_popup_menu;
+
+ if (get_menu_item_info)
+ {
+ /* If there is no popup menu active, free the strings from the frame's
+ menubar. */
+ if (!menu)
+ menu = GetMenu (hwnd);
+
+ if (menu)
+ w32_free_submenu_strings (menu);
+ }
+
+ current_popup_menu = NULL;
+}
+