Mercurial > vim
comparison src/gui_w32.c @ 12668:637096f179c4 v8.0.1212
patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
commit https://github.com/vim/vim/commit/66857f410426ca335f4771a58a32b2d14a7e52b9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 22 16:43:20 2017 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 22 Oct 2017 16:45:04 +0200 |
parents | 856a840679e3 |
children | 25f7d8ee04c7 |
comparison
equal
deleted
inserted
replaced
12667:b5ef7dbff3b8 | 12668:637096f179c4 |
---|---|
7566 } | 7566 } |
7567 | 7567 |
7568 | 7568 |
7569 #ifdef FEAT_TEAROFF | 7569 #ifdef FEAT_TEAROFF |
7570 /* | 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 | |
7590 /* | |
7571 * The callback function for all the modeless dialogs that make up the | 7591 * The callback function for all the modeless dialogs that make up the |
7572 * "tearoff menus" Very simple - forward button presses (to fool Vim into | 7592 * "tearoff menus" Very simple - forward button presses (to fool Vim into |
7573 * thinking its menus have been clicked), and go away when closed. | 7593 * thinking its menus have been clicked), and go away when closed. |
7574 */ | 7594 */ |
7575 static LRESULT CALLBACK | 7595 static LRESULT CALLBACK |
7578 UINT message, | 7598 UINT message, |
7579 WPARAM wParam, | 7599 WPARAM wParam, |
7580 LPARAM lParam) | 7600 LPARAM lParam) |
7581 { | 7601 { |
7582 if (message == WM_INITDIALOG) | 7602 if (message == WM_INITDIALOG) |
7603 { | |
7604 SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam); | |
7583 return (TRUE); | 7605 return (TRUE); |
7606 } | |
7584 | 7607 |
7585 /* May show the mouse pointer again. */ | 7608 /* May show the mouse pointer again. */ |
7586 HandleMouseHide(message, lParam); | 7609 HandleMouseHide(message, lParam); |
7587 | 7610 |
7588 if (message == WM_COMMAND) | 7611 if (message == WM_COMMAND) |
7592 POINT mp; | 7615 POINT mp; |
7593 RECT rect; | 7616 RECT rect; |
7594 | 7617 |
7595 if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect)) | 7618 if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect)) |
7596 { | 7619 { |
7620 vimmenu_T *menu; | |
7621 | |
7622 menu = (vimmenu_T*)GetWindowLongPtr(hwnd, DWLP_USER); | |
7597 (void)TrackPopupMenu( | 7623 (void)TrackPopupMenu( |
7598 (HMENU)(long_u)(LOWORD(wParam) ^ 0x8000), | 7624 tearoff_lookup_menuhandle(menu, LOWORD(wParam)), |
7599 TPM_LEFTALIGN | TPM_LEFTBUTTON, | 7625 TPM_LEFTALIGN | TPM_LEFTBUTTON, |
7600 (int)rect.right - 8, | 7626 (int)rect.right - 8, |
7601 (int)mp.y, | 7627 (int)mp.y, |
7602 (int)0, /*reserved param*/ | 7628 (int)0, /*reserved param*/ |
7603 s_hwnd, | 7629 s_hwnd, |
7705 DWORD lStyle; | 7731 DWORD lStyle; |
7706 DWORD lExtendedStyle; | 7732 DWORD lExtendedStyle; |
7707 WORD dlgwidth; | 7733 WORD dlgwidth; |
7708 WORD menuID; | 7734 WORD menuID; |
7709 vimmenu_T *pmenu; | 7735 vimmenu_T *pmenu; |
7736 vimmenu_T *top_menu; | |
7710 vimmenu_T *the_menu = menu; | 7737 vimmenu_T *the_menu = menu; |
7711 HWND hwnd; | 7738 HWND hwnd; |
7712 HDC hdc; | 7739 HDC hdc; |
7713 HFONT font, oldFont; | 7740 HFONT font, oldFont; |
7714 int col, spaceWidth, len; | 7741 int col, spaceWidth, len; |
7883 */ | 7910 */ |
7884 if (STRCMP(menu->children->name, TEAR_STRING) == 0) | 7911 if (STRCMP(menu->children->name, TEAR_STRING) == 0) |
7885 menu = menu->children->next; | 7912 menu = menu->children->next; |
7886 else | 7913 else |
7887 menu = menu->children; | 7914 menu = menu->children; |
7915 top_menu = menu; | |
7888 for ( ; menu != NULL; menu = menu->next) | 7916 for ( ; menu != NULL; menu = menu->next) |
7889 { | 7917 { |
7890 if (menu->modes == 0) /* this menu has just been deleted */ | 7918 if (menu->modes == 0) /* this menu has just been deleted */ |
7891 continue; | 7919 continue; |
7892 if (menu_is_separator(menu->dname)) | 7920 if (menu_is_separator(menu->dname)) |
7993 | 8021 |
7994 *ptrueheight = (WORD)(sepPadding + 1 + 13 * (*pnumitems)); | 8022 *ptrueheight = (WORD)(sepPadding + 1 + 13 * (*pnumitems)); |
7995 | 8023 |
7996 | 8024 |
7997 /* show modelessly */ | 8025 /* show modelessly */ |
7998 the_menu->tearoff_handle = CreateDialogIndirect( | 8026 the_menu->tearoff_handle = CreateDialogIndirectParam( |
7999 s_hinst, | 8027 s_hinst, |
8000 (LPDLGTEMPLATE)pdlgtemplate, | 8028 (LPDLGTEMPLATE)pdlgtemplate, |
8001 s_hwnd, | 8029 s_hwnd, |
8002 (DLGPROC)tearoff_callback); | 8030 (DLGPROC)tearoff_callback, |
8031 (LPARAM)top_menu); | |
8003 | 8032 |
8004 LocalFree(LocalHandle(pdlgtemplate)); | 8033 LocalFree(LocalHandle(pdlgtemplate)); |
8005 SelectFont(hdc, oldFont); | 8034 SelectFont(hdc, oldFont); |
8006 DeleteObject(font); | 8035 DeleteObject(font); |
8007 ReleaseDC(hwnd, hdc); | 8036 ReleaseDC(hwnd, hdc); |