Skip to content

Commit 66857f4

Browse files
committed
patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
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)
1 parent ca05aa2 commit 66857f4

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

src/gui_w32.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7567,6 +7567,26 @@ nCopyAnsiToWideChar(
75677567

75687568

75697569
#ifdef FEAT_TEAROFF
7570+
/*
7571+
* Lookup menu handle from "menu_id".
7572+
*/
7573+
static HMENU
7574+
tearoff_lookup_menuhandle(
7575+
vimmenu_T *menu,
7576+
WORD menu_id)
7577+
{
7578+
for ( ; menu != NULL; menu = menu->next)
7579+
{
7580+
if (menu->modes == 0) /* this menu has just been deleted */
7581+
continue;
7582+
if (menu_is_separator(menu->dname))
7583+
continue;
7584+
if ((WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000) == menu_id)
7585+
return menu->submenu_id;
7586+
}
7587+
return NULL;
7588+
}
7589+
75707590
/*
75717591
* The callback function for all the modeless dialogs that make up the
75727592
* "tearoff menus" Very simple - forward button presses (to fool Vim into
@@ -7580,7 +7600,10 @@ tearoff_callback(
75807600
LPARAM lParam)
75817601
{
75827602
if (message == WM_INITDIALOG)
7603+
{
7604+
SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
75837605
return (TRUE);
7606+
}
75847607

75857608
/* May show the mouse pointer again. */
75867609
HandleMouseHide(message, lParam);
@@ -7594,8 +7617,11 @@ tearoff_callback(
75947617

75957618
if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
75967619
{
7620+
vimmenu_T *menu;
7621+
7622+
menu = (vimmenu_T*)GetWindowLongPtr(hwnd, DWLP_USER);
75977623
(void)TrackPopupMenu(
7598-
(HMENU)(long_u)(LOWORD(wParam) ^ 0x8000),
7624+
tearoff_lookup_menuhandle(menu, LOWORD(wParam)),
75997625
TPM_LEFTALIGN | TPM_LEFTBUTTON,
76007626
(int)rect.right - 8,
76017627
(int)mp.y,
@@ -7707,6 +7733,7 @@ gui_mch_tearoff(
77077733
WORD dlgwidth;
77087734
WORD menuID;
77097735
vimmenu_T *pmenu;
7736+
vimmenu_T *top_menu;
77107737
vimmenu_T *the_menu = menu;
77117738
HWND hwnd;
77127739
HDC hdc;
@@ -7885,6 +7912,7 @@ gui_mch_tearoff(
78857912
menu = menu->children->next;
78867913
else
78877914
menu = menu->children;
7915+
top_menu = menu;
78887916
for ( ; menu != NULL; menu = menu->next)
78897917
{
78907918
if (menu->modes == 0) /* this menu has just been deleted */
@@ -7995,11 +8023,12 @@ gui_mch_tearoff(
79958023

79968024

79978025
/* show modelessly */
7998-
the_menu->tearoff_handle = CreateDialogIndirect(
8026+
the_menu->tearoff_handle = CreateDialogIndirectParam(
79998027
s_hinst,
80008028
(LPDLGTEMPLATE)pdlgtemplate,
80018029
s_hwnd,
8002-
(DLGPROC)tearoff_callback);
8030+
(DLGPROC)tearoff_callback,
8031+
(LPARAM)top_menu);
80038032

80048033
LocalFree(LocalHandle(pdlgtemplate));
80058034
SelectFont(hdc, oldFont);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1212,
764766
/**/
765767
1211,
766768
/**/

0 commit comments

Comments
 (0)