Skip to content

Commit

Permalink
ドラッグ操作でタブの並び替え、最後のタブより右の位置にドラッグした場合に最後のタブの位置にする
Browse files Browse the repository at this point in the history
  • Loading branch information
beru committed Nov 24, 2019
1 parent ee7b9af commit 3c72455
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions sakura_core/window/CTabWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "util/module.h"
#include "util/string_ex2.h"
#include "sakura_rc.h"
#include <windowsx.h>

//#if(WINVER >= 0x0500)
#ifndef SPI_GETFOREGROUNDLOCKTIMEOUT
Expand Down Expand Up @@ -312,11 +313,22 @@ LRESULT CTabWnd::OnTabMouseMove( WPARAM wParam, LPARAM lParam )
{
TCHITTESTINFO hitinfo;
int i;
int nTabCount;
hitinfo.pt.x = LOWORD( (DWORD)lParam );
hitinfo.pt.y = HIWORD( (DWORD)lParam );
int nTabCount = TabCtrl_GetItemCount(m_hwndTab);
hitinfo.pt.x = GET_X_LPARAM( lParam );
hitinfo.pt.y = GET_Y_LPARAM( lParam );
int nDstTab = TabCtrl_HitTest( m_hwndTab, (LPARAM)&hitinfo );

// 最後のタブより右の位置にドラッグした場合に最後のタブの位置にする
if (nDstTab == -1 && m_nTabBorderArray) {
if (hitinfo.pt.x >= m_nTabBorderArray[nTabCount - 1]) {
RECT rc;
GetClientRect(m_hwndTab, &rc);
if (hitinfo.pt.y >= rc.top && hitinfo.pt.y < rc.bottom) {
nDstTab = nTabCount - 1;
}
}
}

// 各タブの閉じるボタン描画用処理
EDispTabClose bDispTabClose = m_pShareData->m_Common.m_sTabBar.m_bDispTabClose;
if( bDispTabClose && ::GetCapture() != m_hwndTab ){
Expand Down Expand Up @@ -393,8 +405,8 @@ LRESULT CTabWnd::OnTabMouseMove( WPARAM wParam, LPARAM lParam )
if( m_nTabBorderArray ){
delete[] m_nTabBorderArray;
}
m_nTabBorderArray = new LONG[nTabCount];
for (i = 0 ; i < nTabCount-1; i++) {
m_nTabBorderArray = new LONG[nTabCount + 1];
for (i = 0 ; i < nTabCount; i++) {
RECT rc;
TabCtrl_GetItemRect(m_hwndTab, i, &rc);
m_nTabBorderArray[ i ] = rc.right;
Expand All @@ -418,6 +430,8 @@ LRESULT CTabWnd::OnTabMouseMove( WPARAM wParam, LPARAM lParam )
break;
}
}
if (nDstTab >= nTabCount)
nDstTab = nTabCount - 1;

// ドラッグ中に即時移動
if( m_nSrcTab != nDstTab )
Expand Down

0 comments on commit 3c72455

Please sign in to comment.