comparison src/w32menu.c @ 48375:4d7b83cc03aa

Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
author Ben Key <bkey1@tampabay.rr.com>
date Sun, 17 Nov 2002 22:35:26 +0000
parents 52f36f4b0e4f
children f0df5f687c15
comparison
equal deleted inserted replaced
48374:a6f9803f174f 48375:4d7b83cc03aa
127 #define FALSE 0 127 #define FALSE 0
128 #endif /* no TRUE */ 128 #endif /* no TRUE */
129 129
130 static HMENU current_popup_menu; 130 static HMENU current_popup_menu;
131 131
132 FARPROC get_menu_item_info; 132 void syms_of_w32menu ();
133 FARPROC set_menu_item_info; 133
134 typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) (
135 IN HMENU,
136 IN UINT,
137 IN BOOL,
138 IN OUT LPMENUITEMINFOA
139 );
140 typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) (
141 IN HMENU,
142 IN UINT,
143 IN BOOL,
144 IN LPCMENUITEMINFOA
145 );
146
147 GetMenuItemInfoA_Proc get_menu_item_info=NULL;
148 SetMenuItemInfoA_Proc set_menu_item_info=NULL;
134 149
135 Lisp_Object Vmenu_updating_frame; 150 Lisp_Object Vmenu_updating_frame;
136 151
137 Lisp_Object Qdebug_on_next_call; 152 Lisp_Object Qdebug_on_next_call;
138 153
1589 1604
1590 void 1605 void
1591 initialize_frame_menubar (f) 1606 initialize_frame_menubar (f)
1592 FRAME_PTR f; 1607 FRAME_PTR f;
1593 { 1608 {
1609 HMODULE user32 = GetModuleHandle ("user32.dll");
1610 /*
1611 Reinitialize the function pointers set_menu_item_info and
1612 get_menu_item_info here.
1613 Even though these function pointers are initialized in
1614 syms_of_w32menu which is called from main (emacs.c),
1615 we need to initialize them again here in order to prevent
1616 a crash that occurs in Windows 9x (possibly only when Emacs
1617 was built on Windows NT / 2000 / XP?) in add_menu_item.
1618 The crash occurs when attempting to call the Win32 API
1619 function SetMenuItemInfo through the function pointer.
1620 It appears as if the function pointer that is obtained when
1621 syms_of_w32menu is called from main is no longer valid
1622 (possibly due to DLL relocation?).
1623 To resolve this issue, I have placed calls to reinitialize
1624 these function pointers here because this function is the
1625 entry point for menu creation.
1626 */
1627 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
1628 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
1594 /* This function is called before the first chance to redisplay 1629 /* This function is called before the first chance to redisplay
1595 the frame. It has to be, so the frame will have the right size. */ 1630 the frame. It has to be, so the frame will have the right size. */
1596 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); 1631 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
1597 set_frame_menubar (f, 1, 1); 1632 set_frame_menubar (f, 1, 1);
1598 } 1633 }
2353 current_popup_menu = NULL; 2388 current_popup_menu = NULL;
2354 } 2389 }
2355 2390
2356 #endif /* HAVE_MENUS */ 2391 #endif /* HAVE_MENUS */
2357 2392
2358 2393 void syms_of_w32menu ()
2359 syms_of_w32menu ()
2360 { 2394 {
2361 /* See if Get/SetMenuItemInfo functions are available. */ 2395 /* See if Get/SetMenuItemInfo functions are available. */
2362 HMODULE user32 = GetModuleHandle ("user32.dll"); 2396 HMODULE user32 = GetModuleHandle ("user32.dll");
2363 get_menu_item_info = GetProcAddress (user32, "GetMenuItemInfoA"); 2397 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
2364 set_menu_item_info = GetProcAddress (user32, "SetMenuItemInfoA"); 2398 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
2365 2399
2366 staticpro (&menu_items); 2400 staticpro (&menu_items);
2367 menu_items = Qnil; 2401 menu_items = Qnil;
2368 2402
2369 current_popup_menu = NULL; 2403 current_popup_menu = NULL;