Subject: Re: bug#8562: Emacs 23.1 and later don't work in windows 98

From: oslsachem <[email-masked]>
Date: Sun, 12 Jun 2011 23:47:33 +0200

>> In a second build, I have tried using the unicows implementation of
>> AppendMenuW and I have noticed that the menu items tooltips no longer
>> show.
>
> So it looks like we are better off without libunicows, with using
> function pointers to call the crucial several functions needed for
> normal display.

I didn't remember the libunicows build of emacs not showing the menu
items tooltips so I checked it, and it actually showed them.

So, reviewing globals_of_w32menu:

globals_of_w32menu ()
{
  /* See if Get/SetMenuItemInfo functions are available.  */
  HMODULE user32 = GetModuleHandle ("user32.dll");
  get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32,
"GetMenuItemInfoA");
  set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32,
"SetMenuItemInfoA");
  unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32,
"AppendMenuW");
}

I realized that I had carelessly replaced all the occurrences of
'user32' with 'unicows' expecting that:
- At this point in the execution, the unicows library would be already
loaded, which seems to be true.
- Unicows would provide the most up-to-date implementations of the
ansi versions of these functions, which is false.  In general, unicows
only provides the ansi implementations for a few of the functions.  In
particular, unicows doesn't provide the ansi implementations for these
specific functions.

So the change correctly done (supposing the is_windows_9x() function
was available for this file) could be something like :

void
globals_of_w32menu ()
{
  /* See if Get/SetMenuItemInfo functions are available.  */
  HMODULE user32 = GetModuleHandle ("user32.dll");
  get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32,
"GetMenuItemInfoA");
  set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32,
"SetMenuItemInfoA");
  if (is_windows_9x())
    {
      HMODULE unicows = GetModuleHandle ("unicows.dll");
      unicode_append_menu = (AppendMenuW_Proc) GetProcAddress
(unicows, "AppendMenuW");
    }
  else unicode_append_menu = (AppendMenuW_Proc) GetProcAddress
(user32, "AppendMenuW");
}

I think it would be interesting to make this change given that this
unicode function is already called through function pointers and that
this would keep the execution branches of windows 9x and windows NT as
close as possible.

Greetings,
                 Osl