forked from aniani/vim
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)
This commit is contained in:
@@ -7567,6 +7567,26 @@ nCopyAnsiToWideChar(
|
|||||||
|
|
||||||
|
|
||||||
#ifdef FEAT_TEAROFF
|
#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
|
* The callback function for all the modeless dialogs that make up the
|
||||||
* "tearoff menus" Very simple - forward button presses (to fool Vim into
|
* "tearoff menus" Very simple - forward button presses (to fool Vim into
|
||||||
@@ -7580,7 +7600,10 @@ tearoff_callback(
|
|||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (message == WM_INITDIALOG)
|
if (message == WM_INITDIALOG)
|
||||||
|
{
|
||||||
|
SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/* May show the mouse pointer again. */
|
/* May show the mouse pointer again. */
|
||||||
HandleMouseHide(message, lParam);
|
HandleMouseHide(message, lParam);
|
||||||
@@ -7594,8 +7617,11 @@ tearoff_callback(
|
|||||||
|
|
||||||
if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
|
if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
|
||||||
{
|
{
|
||||||
|
vimmenu_T *menu;
|
||||||
|
|
||||||
|
menu = (vimmenu_T*)GetWindowLongPtr(hwnd, DWLP_USER);
|
||||||
(void)TrackPopupMenu(
|
(void)TrackPopupMenu(
|
||||||
(HMENU)(long_u)(LOWORD(wParam) ^ 0x8000),
|
tearoff_lookup_menuhandle(menu, LOWORD(wParam)),
|
||||||
TPM_LEFTALIGN | TPM_LEFTBUTTON,
|
TPM_LEFTALIGN | TPM_LEFTBUTTON,
|
||||||
(int)rect.right - 8,
|
(int)rect.right - 8,
|
||||||
(int)mp.y,
|
(int)mp.y,
|
||||||
@@ -7707,6 +7733,7 @@ gui_mch_tearoff(
|
|||||||
WORD dlgwidth;
|
WORD dlgwidth;
|
||||||
WORD menuID;
|
WORD menuID;
|
||||||
vimmenu_T *pmenu;
|
vimmenu_T *pmenu;
|
||||||
|
vimmenu_T *top_menu;
|
||||||
vimmenu_T *the_menu = menu;
|
vimmenu_T *the_menu = menu;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
@@ -7885,6 +7912,7 @@ gui_mch_tearoff(
|
|||||||
menu = menu->children->next;
|
menu = menu->children->next;
|
||||||
else
|
else
|
||||||
menu = menu->children;
|
menu = menu->children;
|
||||||
|
top_menu = menu;
|
||||||
for ( ; menu != NULL; menu = menu->next)
|
for ( ; menu != NULL; menu = menu->next)
|
||||||
{
|
{
|
||||||
if (menu->modes == 0) /* this menu has just been deleted */
|
if (menu->modes == 0) /* this menu has just been deleted */
|
||||||
@@ -7995,11 +8023,12 @@ gui_mch_tearoff(
|
|||||||
|
|
||||||
|
|
||||||
/* show modelessly */
|
/* show modelessly */
|
||||||
the_menu->tearoff_handle = CreateDialogIndirect(
|
the_menu->tearoff_handle = CreateDialogIndirectParam(
|
||||||
s_hinst,
|
s_hinst,
|
||||||
(LPDLGTEMPLATE)pdlgtemplate,
|
(LPDLGTEMPLATE)pdlgtemplate,
|
||||||
s_hwnd,
|
s_hwnd,
|
||||||
(DLGPROC)tearoff_callback);
|
(DLGPROC)tearoff_callback,
|
||||||
|
(LPARAM)top_menu);
|
||||||
|
|
||||||
LocalFree(LocalHandle(pdlgtemplate));
|
LocalFree(LocalHandle(pdlgtemplate));
|
||||||
SelectFont(hdc, oldFont);
|
SelectFont(hdc, oldFont);
|
||||||
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1212,
|
||||||
/**/
|
/**/
|
||||||
1211,
|
1211,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user