*** src/gui_w32.c Fri Feb 17 00:30:36 2012 --- src/gui_w32.c.mod Fri Feb 17 00:31:10 2012 *************** *** 4283,4288 **** --- 4283,4349 ---- #endif #if defined(FEAT_GUI_TABLINE) || defined(PROTO) + static tabpage_T* s_tp; + static LONG DefTabControlProc; + static tabpage_T* GetTabFromPoint(HWND hWnd, POINT pt){ + tabpage_T* ptp; + ptp = NULL; + if (gui_mch_showing_tabline()){ + TCHITTESTINFO htinfo; + htinfo.pt = pt; + /* ignore if a window under cusor is not tabcontrol. */ + if (s_tabhwnd == hWnd){ + 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){ + POINT pt; + switch (uMsg){ + case WM_MBUTTONDOWN: + { + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + s_tp = GetTabFromPoint(hWnd, pt); + SetCapture(hWnd); + break; + } + case WM_MBUTTONUP: + { + ReleaseCapture(); + /* when the mouse events was executed on the same tab */ + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + if (GetTabFromPoint(hWnd, pt) == 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); + } + s_tp = NULL; + break; + } + default: + break; + } + /* call default TabControl proc */ + return CallWindowProc(DefTabControlProc, hWnd, uMsg, wParam, lParam); + } static void initialise_tabline(void) { *************** *** 4293,4298 **** --- 4354,4361 ---- 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