summaryrefslogtreecommitdiff
path: root/src/gui_w32.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-04-02 22:15:55 +0200
committerBram Moolenaar <Bram@vim.org>2019-04-02 22:15:55 +0200
commit0eb035c974c47e65d32439b48e5a056b370ad429 (patch)
treeae2c351889a6b6e7a42a2b74f7e961e275ca26f6 /src/gui_w32.c
parentb26705afb55955306ffbe2a390e02fc052802b77 (diff)
downloadvim-git-0eb035c974c47e65d32439b48e5a056b370ad429.tar.gz
patch 8.1.1103: MS-Windows: old API calls are no longer neededv8.1.1103
Problem: MS-Windows: old API calls are no longer needed. Solution: Always use the wide functions. (Ken Takata, closes #4199)
Diffstat (limited to 'src/gui_w32.c')
-rw-r--r--src/gui_w32.c530
1 files changed, 135 insertions, 395 deletions
diff --git a/src/gui_w32.c b/src/gui_w32.c
index 292fbdd40..10af357cc 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -313,12 +313,11 @@ static int s_busy_processing = FALSE;
static int destroying = FALSE; /* call DestroyWindow() ourselves */
#ifdef MSWIN_FIND_REPLACE
-static UINT s_findrep_msg = 0; /* set in gui_w[16/32].c */
-static FINDREPLACE s_findrep_struct;
-static FINDREPLACEW s_findrep_struct_w;
+static UINT s_findrep_msg = 0; // set in gui_w[16/32].c
+static FINDREPLACEW s_findrep_struct;
static HWND s_findrep_hwnd = NULL;
-static int s_findrep_is_find; /* TRUE for find dialog, FALSE
- for find/replace dialog */
+static int s_findrep_is_find; // TRUE for find dialog, FALSE
+ // for find/replace dialog
#endif
static HINSTANCE s_hinst = NULL;
@@ -391,7 +390,7 @@ directx_binddc(void)
}
#endif
-/* use of WindowProc depends on wide_WindowProc */
+/* use of WindowProc depends on Global IME */
#define MyWindowProc vim_WindowProc
extern int current_font_height; /* this is in os_mswin.c */
@@ -1107,43 +1106,6 @@ _OnMenu(
#ifdef MSWIN_FIND_REPLACE
/*
- * copy useful data from structure LPFINDREPLACE to structure LPFINDREPLACEW
- */
- static void
-findrep_atow(LPFINDREPLACEW lpfrw, LPFINDREPLACE lpfr)
-{
- WCHAR *wp;
-
- lpfrw->hwndOwner = lpfr->hwndOwner;
- lpfrw->Flags = lpfr->Flags;
-
- wp = enc_to_utf16((char_u *)lpfr->lpstrFindWhat, NULL);
- wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1);
- vim_free(wp);
-
- /* the field "lpstrReplaceWith" doesn't need to be copied */
-}
-
-/*
- * copy useful data from structure LPFINDREPLACEW to structure LPFINDREPLACE
- */
- static void
-findrep_wtoa(LPFINDREPLACE lpfr, LPFINDREPLACEW lpfrw)
-{
- char_u *p;
-
- lpfr->Flags = lpfrw->Flags;
-
- p = utf16_to_enc((short_u*)lpfrw->lpstrFindWhat, NULL);
- vim_strncpy((char_u *)lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1);
- vim_free(p);
-
- p = utf16_to_enc((short_u*)lpfrw->lpstrReplaceWith, NULL);
- vim_strncpy((char_u *)lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
- vim_free(p);
-}
-
-/*
* Handle a Find/Replace window message.
*/
static void
@@ -1152,11 +1114,6 @@ _OnFindRepl(void)
int flags = 0;
int down;
- /* If the OS is Windows NT, and 'encoding' differs from active codepage:
- * convert text from wide string. */
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w);
-
if (s_findrep_struct.Flags & FR_DIALOGTERM)
/* Give main window the focus back. */
(void)SetFocus(s_hwnd);
@@ -1184,14 +1141,20 @@ _OnFindRepl(void)
if (flags != 0)
{
+ char_u *p, *q;
+
/* Call the generic GUI function to do the actual work. */
if (s_findrep_struct.Flags & FR_WHOLEWORD)
flags |= FRD_WHOLE_WORD;
if (s_findrep_struct.Flags & FR_MATCHCASE)
flags |= FRD_MATCH_CASE;
down = (s_findrep_struct.Flags & FR_DOWN) != 0;
- gui_do_findrepl(flags, (char_u *)s_findrep_struct.lpstrFindWhat,
- (char_u *)s_findrep_struct.lpstrReplaceWith, down);
+ p = utf16_to_enc(s_findrep_struct.lpstrFindWhat, NULL);
+ q = utf16_to_enc(s_findrep_struct.lpstrReplaceWith, NULL);
+ if (p != NULL && q != NULL)
+ gui_do_findrepl(flags, p, q, down);
+ vim_free(p);
+ vim_free(q);
}
}
#endif
@@ -1310,9 +1273,7 @@ vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
#ifdef GLOBAL_IME
return global_ime_DefWindowProc(hwnd, message, wParam, lParam);
#else
- if (wide_WindowProc)
- return DefWindowProcW(hwnd, message, wParam, lParam);
- return DefWindowProc(hwnd, message, wParam, lParam);
+ return DefWindowProcW(hwnd, message, wParam, lParam);
#endif
}
@@ -2332,21 +2293,15 @@ GetTextWidthEnc(HDC hdc, char_u *str, int len)
int n;
int wlen = len;
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- {
- /* 'encoding' differs from active codepage: convert text and use wide
- * function */
- wstr = enc_to_utf16(str, &wlen);
- if (wstr != NULL)
- {
- n = GetTextExtentPointW(hdc, wstr, wlen, &size);
- vim_free(wstr);
- if (n)
- return size.cx;
- }
- }
+ wstr = enc_to_utf16(str, &wlen);
+ if (wstr == NULL)
+ return 0;
- return GetTextWidth(hdc, str, len);
+ n = GetTextExtentPointW(hdc, wstr, wlen, &size);
+ vim_free(wstr);
+ if (n)
+ return size.cx;
+ return 0;
}
static void get_work_area(RECT *spi_rect);
@@ -2423,19 +2378,19 @@ gui_mch_show_toolbar(int showit)
if (showit)
{
# ifndef TB_SETUNICODEFORMAT
- /* For older compilers. We assume this never changes. */
+ // For older compilers. We assume this never changes.
# define TB_SETUNICODEFORMAT 0x2005
# endif
- /* Enable/disable unicode support */
- int uu = (enc_codepage >= 0 && (int)GetACP() != enc_codepage);
- SendMessage(s_toolbarhwnd, TB_SETUNICODEFORMAT, (WPARAM)uu, (LPARAM)0);
+ // Enable unicode support
+ SendMessage(s_toolbarhwnd, TB_SETUNICODEFORMAT, (WPARAM)TRUE,
+ (LPARAM)0);
ShowWindow(s_toolbarhwnd, SW_SHOW);
}
else
ShowWindow(s_toolbarhwnd, SW_HIDE);
}
-/* Then number of bitmaps is fixed. Exit is missing! */
+/* The number of bitmaps is fixed. Exit is missing! */
#define TOOLBAR_BITMAP_COUNT 31
#endif
@@ -2444,40 +2399,21 @@ gui_mch_show_toolbar(int showit)
static void
add_tabline_popup_menu_entry(HMENU pmenu, UINT item_id, char_u *item_text)
{
- WCHAR *wn = NULL;
-
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- {
- /* 'encoding' differs from active codepage: convert menu name
- * and use wide function */
- wn = enc_to_utf16(item_text, NULL);
- if (wn != NULL)
- {
- MENUITEMINFOW infow;
-
- infow.cbSize = sizeof(infow);
- infow.fMask = MIIM_TYPE | MIIM_ID;
- infow.wID = item_id;
- infow.fType = MFT_STRING;
- infow.dwTypeData = wn;
- infow.cch = (UINT)wcslen(wn);
- InsertMenuItemW(pmenu, item_id, FALSE, &infow);
- vim_free(wn);
- }
- }
+ WCHAR *wn;
+ MENUITEMINFOW infow;
+ wn = enc_to_utf16(item_text, NULL);
if (wn == NULL)
- {
- MENUITEMINFO info;
+ return;
- info.cbSize = sizeof(info);
- info.fMask = MIIM_TYPE | MIIM_ID;
- info.wID = item_id;
- info.fType = MFT_STRING;
- info.dwTypeData = (LPTSTR)item_text;
- info.cch = (UINT)STRLEN(item_text);
- InsertMenuItem(pmenu, item_id, FALSE, &info);
- }
+ infow.cbSize = sizeof(infow);
+ infow.fMask = MIIM_TYPE | MIIM_ID;
+ infow.wID = item_id;
+ infow.fType = MFT_STRING;
+ infow.dwTypeData = wn;
+ infow.cch = (UINT)wcslen(wn);
+ InsertMenuItemW(pmenu, item_id, FALSE, &infow);
+ vim_free(wn);
}
static void
@@ -2573,8 +2509,6 @@ gui_mch_update_tabline(void)
int nr = 0;
int curtabidx = 0;
int tabadded = 0;
- static int use_unicode = FALSE;
- int uu;
WCHAR *wstr = NULL;
if (s_tabhwnd == NULL)
@@ -2584,13 +2518,8 @@ gui_mch_update_tabline(void)
/* For older compilers. We assume this never changes. */
# define CCM_SETUNICODEFORMAT 0x2005
#endif
- uu = (enc_codepage >= 0 && (int)GetACP() != enc_codepage);
- if (uu != use_unicode)
- {
- /* Enable/disable unicode support */
- SendMessage(s_tabhwnd, CCM_SETUNICODEFORMAT, (WPARAM)uu, (LPARAM)0);
- use_unicode = uu;
- }
+ // Enable unicode support
+ SendMessage(s_tabhwnd, CCM_SETUNICODEFORMAT, (WPARAM)TRUE, (LPARAM)0);
tie.mask = TCIF_TEXT;
tie.iImage = -1;
@@ -2614,24 +2543,18 @@ gui_mch_update_tabline(void)
get_tabline_label(tp, FALSE);
tie.pszText = (LPSTR)NameBuff;
- wstr = NULL;
- if (use_unicode)
+
+ wstr = enc_to_utf16(NameBuff, NULL);
+ if (wstr != NULL)
{
- /* Need to go through Unicode. */
- wstr = enc_to_utf16(NameBuff, NULL);
- if (wstr != NULL)
- {
- TCITEMW tiw;
+ TCITEMW tiw;
- tiw.mask = TCIF_TEXT;
- tiw.iImage = -1;
- tiw.pszText = wstr;
- SendMessage(s_tabhwnd, TCM_SETITEMW, (WPARAM)nr, (LPARAM)&tiw);
- vim_free(wstr);
- }
+ tiw.mask = TCIF_TEXT;
+ tiw.iImage = -1;
+ tiw.pszText = wstr;
+ SendMessage(s_tabhwnd, TCM_SETITEMW, (WPARAM)nr, (LPARAM)&tiw);
+ vim_free(wstr);
}
- if (wstr == NULL)
- TabCtrl_SetItem(s_tabhwnd, nr, &tie);
}
/* Remove any old labels. */
@@ -2720,8 +2643,17 @@ initialise_findrep(char_u *initial_string)
if (wword)
s_findrep_struct.Flags |= FR_WHOLEWORD;
if (entry_text != NULL && *entry_text != NUL)
- vim_strncpy((char_u *)s_findrep_struct.lpstrFindWhat, entry_text,
- s_findrep_struct.wFindWhatLen - 1);
+ {
+ WCHAR *p = enc_to_utf16(entry_text, NULL);
+ if (p != NULL)
+ {
+ int len = s_findrep_struct.wFindWhatLen - 1;
+
+ wcsncpy(s_findrep_struct.lpstrFindWhat, p, len);
+ s_findrep_struct.lpstrFindWhat[len] = NUL;
+ vim_free(p);
+ }
+ }
vim_free(entry_text);
}
#endif
@@ -2729,7 +2661,7 @@ initialise_findrep(char_u *initial_string)
static void
set_window_title(HWND hwnd, char *title)
{
- if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP())
+ if (title != NULL)
{
WCHAR *wbuf;
@@ -2740,9 +2672,9 @@ set_window_title(HWND hwnd, char *title)
SetWindowTextW(hwnd, wbuf);
vim_free(wbuf);
}
- return;
}
- (void)SetWindowText(hwnd, (LPCSTR)title);
+ else
+ (void)SetWindowTextW(hwnd, NULL);
}
void
@@ -2757,16 +2689,7 @@ gui_mch_find_dialog(exarg_T *eap)
if (!IsWindow(s_findrep_hwnd))
{
initialise_findrep(eap->arg);
- /* If the OS is Windows NT, and 'encoding' differs from active
- * codepage: convert text and use wide function. */
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- {
- findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
- s_findrep_hwnd = FindTextW(
- (LPFINDREPLACEW) &s_findrep_struct_w);
- }
- else
- s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
+ s_findrep_hwnd = FindTextW((LPFINDREPLACEW) &s_findrep_struct);
}
set_window_title(s_findrep_hwnd, _("Find string"));
@@ -2790,15 +2713,7 @@ gui_mch_replace_dialog(exarg_T *eap)
if (!IsWindow(s_findrep_hwnd))
{
initialise_findrep(eap->arg);
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- {
- findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
- s_findrep_hwnd = ReplaceTextW(
- (LPFINDREPLACEW) &s_findrep_struct_w);
- }
- else
- s_findrep_hwnd = ReplaceText(
- (LPFINDREPLACE) &s_findrep_struct);
+ s_findrep_hwnd = ReplaceTextW((LPFINDREPLACEW) &s_findrep_struct);
}
set_window_title(s_findrep_hwnd, _("Find & Replace"));
@@ -4147,7 +4062,6 @@ static UINT s_menu_id = 100;
#define USE_SYSMENU_FONT
#define VIM_NAME "vim"
-#define VIM_CLASS "Vim"
#define VIM_CLASSW L"Vim"
/* Initial size for the dialog template. For gui_mch_dialog() it's fixed,
@@ -5021,9 +4935,6 @@ gui_mch_prepare(int *argc, char **argv)
int
gui_mch_init(void)
{
- const char szVimWndClass[] = VIM_CLASS;
- const char szTextAreaClass[] = "VimTextArea";
- WNDCLASS wndclass;
const WCHAR szVimWndClassW[] = VIM_CLASSW;
const WCHAR szTextAreaClassW[] = L"VimTextArea";
WNDCLASSW wndclassw;
@@ -5073,50 +4984,26 @@ gui_mch_init(void)
#endif
RegisterClassW(&wndclassw)) == 0)
return FAIL;
- else
- wide_WindowProc = TRUE;
}
- if (!wide_WindowProc)
- if (GetClassInfo(s_hinst, szVimWndClass, &wndclass) == 0)
- {
- wndclass.style = CS_DBLCLKS;
- wndclass.lpfnWndProc = _WndProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = s_hinst;
- wndclass.hIcon = LoadIcon(wndclass.hInstance, "IDR_VIM");
- wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
- wndclass.hbrBackground = s_brush;
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = szVimWndClass;
-
- if ((
-#ifdef GLOBAL_IME
- atom =
-#endif
- RegisterClass(&wndclass)) == 0)
- return FAIL;
- }
-
if (vim_parent_hwnd != NULL)
{
#ifdef HAVE_TRY_EXCEPT
__try
{
#endif
- /* Open inside the specified parent window.
- * TODO: last argument should point to a CLIENTCREATESTRUCT
- * structure. */
- s_hwnd = CreateWindowEx(
+ // Open inside the specified parent window.
+ // TODO: last argument should point to a CLIENTCREATESTRUCT
+ // structure.
+ s_hwnd = CreateWindowExW(
WS_EX_MDICHILD,
- szVimWndClass, "Vim MSWindows GUI",
+ szVimWndClassW, L"Vim MSWindows GUI",
WS_OVERLAPPEDWINDOW | WS_CHILD
| WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 0xC000,
gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
- 100, /* Any value will do */
- 100, /* Any value will do */
+ 100, // Any value will do
+ 100, // Any value will do
vim_parent_hwnd, NULL,
s_hinst, NULL);
#ifdef HAVE_TRY_EXCEPT
@@ -5141,8 +5028,8 @@ gui_mch_init(void)
/* Create a window. If win_socket_id is not zero without border and
* titlebar, it will be reparented below. */
- s_hwnd = CreateWindow(
- szVimWndClass, "Vim MSWindows GUI",
+ s_hwnd = CreateWindowW(
+ szVimWndClassW, L"Vim MSWindows GUI",
(win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP)
| WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
@@ -5169,60 +5056,32 @@ gui_mch_init(void)
#endif
/* Create the text area window */
- if (wide_WindowProc)
+ if (GetClassInfoW(s_hinst, szTextAreaClassW, &wndclassw) == 0)
{
- if (GetClassInfoW(s_hinst, szTextAreaClassW, &wndclassw) == 0)
- {
- wndclassw.style = CS_OWNDC;
- wndclassw.lpfnWndProc = _TextAreaWndProc;
- wndclassw.cbClsExtra = 0;
- wndclassw.cbWndExtra = 0;
- wndclassw.hInstance = s_hinst;
- wndclassw.hIcon = NULL;
- wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW);
- wndclassw.hbrBackground = NULL;
- wndclassw.lpszMenuName = NULL;
- wndclassw.lpszClassName = szTextAreaClassW;
-
- if (RegisterClassW(&wndclassw) == 0)
- return FAIL;
- }
+ wndclassw.style = CS_OWNDC;
+ wndclassw.lpfnWndProc = _TextAreaWndProc;
+ wndclassw.cbClsExtra = 0;
+ wndclassw.cbWndExtra = 0;
+ wndclassw.hInstance = s_hinst;
+ wndclassw.hIcon = NULL;
+ wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wndclassw.hbrBackground = NULL;
+ wndclassw.lpszMenuName = NULL;
+ wndclassw.lpszClassName = szTextAreaClassW;
- s_textArea = CreateWindowExW(
- 0,
- szTextAreaClassW, L"Vim text area",
- WS_CHILD | WS_VISIBLE, 0, 0,
- 100, // Any value will do for now
- 100, // Any value will do for now
- s_hwnd, NULL,
- s_hinst, NULL);
- }
- else if (GetClassInfo(s_hinst, szTextAreaClass, &wndclass) == 0)
- {
- wndclass.style = CS_OWNDC;
- wndclass.lpfnWndProc = _TextAreaWndProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = s_hinst;
- wndclass.hIcon = NULL;
- wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
- wndclass.hbrBackground = NULL;
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = szTextAreaClass;
-
- if (RegisterClass(&wndclass) == 0)
+ if (RegisterClassW(&wndclassw) == 0)
return FAIL;
-
- s_textArea = CreateWindowEx(
- 0,
- szTextAreaClass, "Vim text area",
- WS_CHILD | WS_VISIBLE, 0, 0,
- 100, // Any value will do for now
- 100, // Any value will do for now
- s_hwnd, NULL,
- s_hinst, NULL);
}
+ s_textArea = CreateWindowExW(
+ 0,
+ szTextAreaClassW, L"Vim text area",
+ WS_CHILD | WS_VISIBLE, 0, 0,
+ 100, // Any value will do for now
+ 100, // Any value will do for now
+ s_hwnd, NULL,
+ s_hinst, NULL);
+
if (s_textArea == NULL)
return FAIL;
@@ -5299,21 +5158,14 @@ gui_mch_init(void)
/* Initialise the struct */
s_findrep_struct.lStructSize = sizeof(s_findrep_struct);
- s_findrep_struct.lpstrFindWhat = (LPSTR)alloc(MSWIN_FR_BUFSIZE);
+ s_findrep_struct.lpstrFindWhat =
+ (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
s_findrep_struct.lpstrFindWhat[0] = NUL;
- s_findrep_struct.lpstrReplaceWith = (LPSTR)alloc(MSWIN_FR_BUFSIZE);
+ s_findrep_struct.lpstrReplaceWith =
+ (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
s_findrep_struct.lpstrReplaceWith[0] = NUL;
s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
- s_findrep_struct_w.lStructSize = sizeof(s_findrep_struct_w);
- s_findrep_struct_w.lpstrFindWhat =
- (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
- s_findrep_struct_w.lpstrFindWhat[0] = NUL;
- s_findrep_struct_w.lpstrReplaceWith =
- (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
- s_findrep_struct_w.lpstrReplaceWith[0] = NUL;
- s_findrep_struct_w.wFindWhatLen = MSWIN_FR_BUFSIZE;
- s_findrep_struct_w.wReplaceWithLen = MSWIN_FR_BUFSIZE;
#endif
#ifdef FEAT_EVAL
@@ -6344,49 +6196,26 @@ gui_mch_add_menu(
if (menu_is_menubar(menu->name))
{
- WCHAR *wn = NULL;
-
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- {
- /* 'encoding' differs from active codepage: convert menu name
- * and use wide function */
- wn = enc_to_utf16(menu->name, NULL);
- if (wn != NULL)
- {
- MENUITEMINFOW infow;
-
- infow.cbSize = sizeof(infow);
- infow.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID
- | MIIM_SUBMENU;
- infow.dwItemData = (long_u)menu;
- infow.wID = menu->id;
- infow.fType = MFT_STRING;
- infow.dwTypeData = wn;
- infow.cch = (UINT)wcslen(wn);
- infow.hSubMenu = menu->submenu_id;
- InsertMenuItemW((parent == NULL)
- ? s_menuBar : parent->submenu_id,
- (UINT)pos, TRUE, &infow);
- vim_free(wn);
- }
- }
+ WCHAR *wn;
+ MENUITEMINFOW infow;
+ wn = enc_to_utf16(menu->name, NULL);
if (wn == NULL)
- {
- MENUITEMINFO info;
-
- info.cbSize = sizeof(info);
- info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID | MIIM_SUBMENU;
- info.dwItemData = (long_u)menu;
- info.wID = menu->id;
- info.fType = MFT_STRING;
- info.dwTypeData = (LPTSTR)menu->name;
- info.cch = (UINT)STRLEN(menu->name);
- info.hSubMenu = menu->submenu_id;
- InsertMenuItem((parent == NULL)
- ? s_menuBar : parent->submenu_id,
- (UINT)pos, TRUE, &info);
- }
+ return;
+
+ infow.cbSize = sizeof(infow);
+ infow.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID
+ | MIIM_SUBMENU;
+ infow.dwItemData = (long_u)menu;
+ infow.wID = menu->id;
+ infow.fType = MFT_STRING;
+ infow.dwTypeData = wn;
+ infow.cch = (UINT)wcslen(wn);
+ infow.hSubMenu = menu->submenu_id;
+ InsertMenuItemW((parent == NULL)
+ ? s_menuBar : parent->submenu_id,
+ (UINT)pos, TRUE, &infow);
+ vim_free(wn);
}
/* Fix window size if menu may have wrapped */
@@ -6499,27 +6328,17 @@ gui_mch_add_menu_item(
else
#endif
{
- WCHAR *wn = NULL;
+ WCHAR *wn;
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ wn = enc_to_utf16(menu->name, NULL);
+ if (wn != NULL)
{
- /* 'encoding' differs from active codepage: convert menu item name
- * and use wide function */
- wn = enc_to_utf16(menu->name, NULL);
- if (wn != NULL)
- {
- InsertMenuW(parent->submenu_id, (UINT)idx,
- (menu_is_separator(menu->name)
- ? MF_SEPARATOR : MF_STRING) | MF_BYPOSITION,
- (UINT)menu->id, wn);
- vim_free(wn);
- }
+ InsertMenuW(parent->submenu_id, (UINT)idx,
+ (menu_is_separator(menu->name)
+ ? MF_SEPARATOR : MF_STRING) | MF_BYPOSITION,
+ (UINT)menu->id, wn);
+ vim_free(wn);
}
- if (wn == NULL)
- InsertMenu(parent->submenu_id, (UINT)idx,
- (menu_is_separator(menu->name) ? MF_SEPARATOR : MF_STRING)
- | MF_BYPOSITION,
- (UINT)menu->id, (LPCTSTR)menu->name);
#ifdef FEAT_TEAROFF
if (IsWindow(parent->tearoff_handle))
rebuild_tearoff(parent);
@@ -6709,22 +6528,14 @@ dialog_callback(
/* If the edit box exists, copy the string. */
if (s_textfield != NULL)
{
- /* If the OS is Windows NT, and 'encoding' differs from active
- * codepage: use wide function and convert text. */
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- {
- WCHAR *wp = (WCHAR *)alloc(IOSIZE * sizeof(WCHAR));
- char_u *p;
-
- GetDlgItemTextW(hwnd, DLG_NONBUTTON_CONTROL + 2, wp, IOSIZE);
- p = utf16_to_enc(wp, NULL);
- vim_strncpy(s_textfield, p, IOSIZE);
- vim_free(p);
- vim_free(wp);
- }
- else
- GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
- (LPSTR)s_textfield, IOSIZE);
+ WCHAR *wp = (WCHAR *)alloc(IOSIZE * sizeof(WCHAR));
+ char_u *p;
+
+ GetDlgItemTextW(hwnd, DLG_NONBUTTON_CONTROL + 2, wp, IOSIZE);
+ p = utf16_to_enc(wp, NULL);
+ vim_strncpy(s_textfield, p, IOSIZE);
+ vim_free(p);
+ vim_free(wp);
}
/*
@@ -8411,7 +8222,7 @@ multiline_balloon_available(void)
}
static void
-make_tooltipw(BalloonEval *beval, char *text, POINT pt)
+make_tooltip(BalloonEval *beval, char *text, POINT pt)
{
TOOLINFOW *pti;
int ToolInfoSize;
@@ -8481,77 +8292,6 @@ make_tooltipw(BalloonEval *beval, char *text, POINT pt)
}
static void
-make_tooltip(BalloonEval *beval, char *text, POINT pt)
-{
- TOOLINFO *pti;
- int ToolInfoSize;
-
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- {
- make_tooltipw(beval, text, pt);
- return;
- }
-
- if (multiline_balloon_available() == TRUE)
- ToolInfoSize = sizeof(TOOLINFO_NEW);
- else
- ToolInfoSize = sizeof(TOOLINFO);
-
- pti = (TOOLINFO *)alloc(ToolInfoSize);
- if (pti == NULL)
- return;
-
- beval->balloon = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS,
- NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- beval->target, NULL, s_hinst, NULL);
-
- SetWindowPos(beval->balloon, HWND_TOPMOST, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
-
- pti->cbSize = ToolInfoSize;
- pti->uFlags = TTF_SUBCLASS;
- pti->hwnd = beval->target;
- pti->hinst = 0; /* Don't use string resources */
- pti->uId = ID_BEVAL_TOOLTIP;
-
- if (multiline_balloon_available() == TRUE)
- {
- RECT rect;
- TOOLINFO_NEW *ptin = (TOOLINFO_NEW *)pti;
- pti->lpszText = LPSTR_TEXTCALLBACK;
- beval->tofree = vim_strsave((char_u*)text);
- ptin->lParam = (LPARAM)beval->tofree;
- if (GetClientRect(s_textArea, &rect)) /* switch multiline tooltips on */
- SendMessage(beval->balloon, TTM_SETMAXTIPWIDTH, 0,
- (LPARAM)rect.right);
- }
- else
- pti->lpszText = text; /* do this old way */
-
- /* Limit ballooneval bounding rect to CursorPos neighbourhood */
- pti->rect.left = pt.x - 3;
- pti->rect.top = pt.y - 3;
- pti->rect.right = pt.x + 3;
- pti->rect.bottom = pt.y + 3;
-
- SendMessage(beval->balloon, TTM_ADDTOOL, 0, (LPARAM)pti);
- /* Make tooltip appear sooner */
- SendMessage(beval->balloon, TTM_SETDELAYTIME, TTDT_INITIAL, 10);
- /* I've performed some tests and it seems the longest possible life time
- * of tooltip is 30 seconds */
- SendMessage(beval->balloon, TTM_SETDELAYTIME, TTDT_AUTOPOP, 30000);
- /*
- * HACK: force tooltip to appear, because it'll not appear until
- * first mouse move. D*mn M$
- * Amazingly moving (2, 2) and then (-1, -1) the mouse doesn't move.
- */
- mouse_event(MOUSEEVENTF_MOVE, 2, 2, 0, 0);
- mouse_event(MOUSEEVENTF_MOVE, (DWORD)-1, (DWORD)-1, 0, 0);
- vim_free(pti);
-}
-
- static void
delete_tooltip(BalloonEval *beval)
{
PostMessage(beval->balloon, WM_CLOSE, 0, 0);