Patch 8.0.1212
Problem:    MS-Windows: tear-off menu does not work on 64 bit. (shaggyaxe)
Solution:   Change how the menu handle is looked up. (Ken Takata, closes
            #1205)
Files:      src/gui_w32.c


*** ../vim-8.0.1211/src/gui_w32.c       2017-10-22 15:36:09.914319084 +0200
--- src/gui_w32.c       2017-10-22 16:43:06.838655066 +0200
***************
*** 7568,7573 ****
--- 7568,7593 ----
  
  #ifdef FEAT_TEAROFF
  /*
+  * Lookup menu handle from "menu_id".
+  */
+     static HMENU
+ tearoff_lookup_menuhandle(
+     vimmenu_T *menu,
+     WORD menu_id)
+ {
+     for ( ; menu != NULL; menu = menu->next)
+     {
+       if (menu->modes == 0)   /* this menu has just been deleted */
+           continue;
+       if (menu_is_separator(menu->dname))
+           continue;
+       if ((WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000) == menu_id)
+           return menu->submenu_id;
+     }
+     return NULL;
+ }
+ 
+ /*
   * The callback function for all the modeless dialogs that make up the
   * "tearoff menus" Very simple - forward button presses (to fool Vim into
   * thinking its menus have been clicked), and go away when closed.
***************
*** 7580,7586 ****
--- 7600,7609 ----
      LPARAM lParam)
  {
      if (message == WM_INITDIALOG)
+     {
+       SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
        return (TRUE);
+     }
  
      /* May show the mouse pointer again. */
      HandleMouseHide(message, lParam);
***************
*** 7594,7601 ****
  
            if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
            {
                (void)TrackPopupMenu(
!                        (HMENU)(long_u)(LOWORD(wParam) ^ 0x8000),
                         TPM_LEFTALIGN | TPM_LEFTBUTTON,
                         (int)rect.right - 8,
                         (int)mp.y,
--- 7617,7627 ----
  
            if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
            {
+               vimmenu_T *menu;
+ 
+               menu = (vimmenu_T*)GetWindowLongPtr(hwnd, DWLP_USER);
                (void)TrackPopupMenu(
!                        tearoff_lookup_menuhandle(menu, LOWORD(wParam)),
                         TPM_LEFTALIGN | TPM_LEFTBUTTON,
                         (int)rect.right - 8,
                         (int)mp.y,
***************
*** 7707,7712 ****
--- 7733,7739 ----
      WORD      dlgwidth;
      WORD      menuID;
      vimmenu_T *pmenu;
+     vimmenu_T *top_menu;
      vimmenu_T *the_menu = menu;
      HWND      hwnd;
      HDC               hdc;
***************
*** 7885,7890 ****
--- 7912,7918 ----
        menu = menu->children->next;
      else
        menu = menu->children;
+     top_menu = menu;
      for ( ; menu != NULL; menu = menu->next)
      {
        if (menu->modes == 0)   /* this menu has just been deleted */
***************
*** 7995,8005 ****
  
  
      /* show modelessly */
!     the_menu->tearoff_handle = CreateDialogIndirect(
            s_hinst,
            (LPDLGTEMPLATE)pdlgtemplate,
            s_hwnd,
!           (DLGPROC)tearoff_callback);
  
      LocalFree(LocalHandle(pdlgtemplate));
      SelectFont(hdc, oldFont);
--- 8023,8034 ----
  
  
      /* show modelessly */
!     the_menu->tearoff_handle = CreateDialogIndirectParam(
            s_hinst,
            (LPDLGTEMPLATE)pdlgtemplate,
            s_hwnd,
!           (DLGPROC)tearoff_callback,
!           (LPARAM)top_menu);
  
      LocalFree(LocalHandle(pdlgtemplate));
      SelectFont(hdc, oldFont);
*** ../vim-8.0.1211/src/version.c       2017-10-22 15:36:09.914319084 +0200
--- src/version.c       2017-10-22 16:41:29.175331125 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1212,
  /**/

-- 
ARTHUR:  Be quiet!
DENNIS:  Well you can't expect to wield supreme executive power just 'cause
         some watery tart threw a sword at you!
ARTHUR:  Shut up!
DENNIS:  I mean, if I went around sayin' I was an empereror just because some
         moistened bint had lobbed a scimitar at me they'd put me away!
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui