*** src/gui_w32.c 2013-08-04 23:15:37.000000000 +0900 --- src/gui_w32.c.mod 2013-11-20 17:43:47.557875000 +0900 *************** *** 4223,4228 **** --- 4223,4333 ---- #endif #if defined(FEAT_GUI_TABLINE) || defined(PROTO) + static tabpage_T* s_tp = NULL; + static LONG DefTabControlProc; + static HCURSOR s_hCursor = NULL; + static POINT s_pt = {0, 0}; + 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_LBUTTONDOWN: + { + s_pt.x = LOWORD(lParam); + s_pt.y = HIWORD(lParam); + s_tp = GetTabFromPoint(hWnd, s_pt); + SetCapture(hWnd); + break; + } + case WM_MOUSEMOVE: + if (GetCapture() == hWnd){ + if (wParam & MK_LBUTTON){ + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + if ( ( (s_pt.x-pt.x)*(s_pt.x-pt.x) + (s_pt.y-pt.y)*(s_pt.y-pt.y) ) > 0xff ){ + s_hCursor = GetCursor(); + SetCursor(LoadCursor(0, IDC_SIZEWE)); + } + } + } + break; + case WM_LBUTTONUP: + { + SetCursor(s_hCursor); + ReleaseCapture(); + /* when the mouse events was executed on the same tab */ + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + tabpage_T* tp = GetTabFromPoint(hWnd, pt); + if (s_tp != NULL && tp != NULL){ + if (tp == s_tp){ + s_tp = NULL; + break; + } + else{ + goto_tabpage_tp(s_tp, TRUE, TRUE); + tabpage_move(tabpage_index(tp)-1); + update_screen(0); + } + } + s_tp = NULL; + break; + } + 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) { *************** *** 4234,4239 **** --- 4339,4346 ---- CW_USEDEFAULT, s_hwnd, NULL, s_hinst, NULL); s_tabline_wndproc = SubclassWindow(s_tabhwnd, tabline_wndproc); + DefTabControlProc = SetWindowLong(s_tabhwnd, GWL_WNDPROC, (LONG)MyTabControlProc); + gui.tabline_height = TABLINE_HEIGHT; # ifdef USE_SYSMENU_FONT