--- src/gui_w32.c 2011-08-06 13:42:23.069250000 +0900 +++ src/gui_w32.c.mod 2011-08-08 19:11:29.640625000 +0900 @@ -4260,6 +4260,64 @@ #endif #if defined(FEAT_GUI_TABLINE) || defined(PROTO) +static tabpage_T* s_tp; +static LONG DefTabControlProc; +static tabpage_T* GetTabUnderCursor(){ + tabpage_T* ptp; + ptp = NULL; + if (gui_mch_showing_tabline()){ + TCHITTESTINFO htinfo; + GetCursorPos(&htinfo.pt); + /* ignore if a window under cusor is not tabcontrol. */ + if (s_tabhwnd == WindowFromPoint(htinfo.pt)){ + if (ScreenToClient(s_tabhwnd, &htinfo.pt) != 0){ + int idx; + idx = TabCtrl_HitTest(s_tabhwnd, &htinfo); + if (idx != -1){ + ptp = find_tabpage(idx + 1); + } + } + } + } + return ptp; +} +static LRESULT CALLBACK MyTabControlProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ + switch (uMsg){ + case WM_MBUTTONDOWN: + { + s_tp = GetTabUnderCursor(); + SetCapture(hWnd); + break; + } + case WM_MBUTTONUP: + { + /* when the mouse events was executed on the same tab */ + if (GetTabUnderCursor() == s_tp){ + BOOL bResult; + bResult = FALSE; + if (s_tp == curtab){ + if (first_tabpage->tp_next != NULL){ + tabpage_close(FALSE); + bResult = TRUE; + } + } + else if (s_tp != NULL){ + tabpage_close_other(s_tp, FALSE); + bResult = TRUE; + } + + if (bResult == TRUE) update_screen(0); + } + ReleaseCapture(); + s_tp = NULL; + break; + } + default: + break; + } + /* call default TabControl proc */ + return CallWindowProc(DefTabControlProc, hWnd, uMsg, wParam, lParam); +} static void initialise_tabline(void) { @@ -4270,6 +4328,8 @@ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, s_hwnd, NULL, s_hinst, NULL); + DefTabControlProc = SetWindowLong(s_tabhwnd, GWL_WNDPROC, (LONG)MyTabControlProc); + gui.tabline_height = TABLINE_HEIGHT; # ifdef USE_SYSMENU_FONT