You came across the really interesting issue related to the unexpected horizontal scrolling in the drag-n-drop enabled tree grid window. To fix it, please update the source code for the CExtGridBaseWnd::OnLButtonUp()
method in the ../Prof-UIS/Src/ExtGridWnd.cpp file:
void CExtGridBaseWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
ASSERT_VALID( this );
if( OnGbwDataDndIsAllowed() && m_eMTT == __EMTT_DATA_DND_STARTING )
{
SendMessage( WM_CANCELMODE );
bool bAlt = ( (::GetAsyncKeyState(VK_MENU)&0x8000) != 0 ) ? true : false;
bool bCtrl = ( (::GetAsyncKeyState(VK_CONTROL)&0x8000) != 0 ) ? true : false;
bool bShift = ( (::GetAsyncKeyState(VK_SHIFT)&0x8000) != 0 ) ? true : false;
bool bCtrlOnly = bCtrl && (!bAlt) && (!bShift);
bool bShiftOnly = (!bCtrl) && (!bAlt) && bShift;
bool bNoModifiers = (!bCtrl) && (!bAlt) && (!bShift);
bool bMultiAreaSelection = MultiAreaSelectionGet();
bool bReplaceOldSelection =
(!bMultiAreaSelection)
|| (!(bCtrlOnly || bShiftOnly));
if( ! ( bCtrlOnly || bNoModifiers ) )
return;
CExtGridHitTestInfo htInfo( point );
HitTest( htInfo, false, true );
DWORD dwSiwStyles = SiwGetStyle();
if( (dwSiwStyles & __EGBS_SFB_MASK) != __EGBS_SFB_NONE
&& ( htInfo.m_nColNo >= 0 || htInfo.m_nRowNo >= 0 )
)
{ // if any selection mode can be tracked
if( (htInfo.m_dwAreaFlags & __EGBWA_INNER_CELLS) != 0 )
{
LONG nColumnCount = ColumnCountGet();
LONG nRowCount = RowCountGet();
if( (dwSiwStyles & __EGBS_SFB_MASK) == __EGBS_SFB_FULL_COLUMNS )
{
if( htInfo.m_nColNo >= 0 )
{
if( bNoModifiers )
{
CPoint ptNewFocus( htInfo.m_nColNo, htInfo.m_nRowNo );
SelectionSet( ptNewFocus, true, false, false );
FocusSet( ptNewFocus, true, true, false, false );
OnSwDoRedraw();
return;
} // if( bNoModifiers )
ASSERT( bCtrlOnly );
if( (dwSiwStyles & __EGBS_SFM_COLUMNS) == 0
|| (! SelectionGetForCell( htInfo.m_nColNo, 0 ) )
|| bReplaceOldSelection
)
return; // processed in WM_LBUTTONDOWN
CRect rcSelection( htInfo.m_nColNo, 0, htInfo.m_nColNo, nRowCount-1 );
SelectionSet( rcSelection, bReplaceOldSelection, false, false );
EnsureVisibleColumn( htInfo.m_nColNo, true );
} // if( htInfo.m_nColNo >= 0 )
return;
} // if( (dwSiwStyles & __EGBS_SFB_MASK) == __EGBS_SFB_FULL_COLUMNS )
else if( (dwSiwStyles & __EGBS_SFB_MASK) == __EGBS_SFB_FULL_ROWS )
{
if( htInfo.m_nRowNo >= 0 )
{
if( bNoModifiers )
{
CPoint ptNewFocus( htInfo.m_nColNo, htInfo.m_nRowNo );
SelectionSet( ptNewFocus, true, false, false );
FocusSet( ptNewFocus, true, true, false, false );
OnSwDoRedraw();
return;
} // if( bNoModifiers )
ASSERT( bCtrlOnly );
if( (dwSiwStyles & __EGBS_SFM_ROWS) == 0
|| (! SelectionGetForCell( 0, htInfo.m_nRowNo ) )
|| bReplaceOldSelection
)
return; // processed in WM_LBUTTONDOWN
CRect rcSelection( 0, htInfo.m_nRowNo, nColumnCount-1, htInfo.m_nRowNo );
SelectionSet( rcSelection, bReplaceOldSelection, false, false );
EnsureVisibleRow( htInfo.m_nRowNo, true );
} // if( htInfo.m_nRowNo >= 0 )
return;
} // else if( (dwSiwStyles & __EGBS_SFB_MASK) == __EGBS_SFB_FULL_ROWS )
else
{
ASSERT( (dwSiwStyles & __EGBS_SFB_MASK) == __EGBS_SFB_CELLS );
DWORD dwScrollTypeH = SiwScrollTypeHGet();
DWORD dwScrollTypeV = SiwScrollTypeVGet();
if( 0 <= htInfo.m_nColNo && (htInfo.m_nColNo < nColumnCount || dwScrollTypeH == __ESIW_ST_VIRTUAL )
&& 0 <= htInfo.m_nRowNo && (htInfo.m_nRowNo < nRowCount || dwScrollTypeV == __ESIW_ST_VIRTUAL )
)
{ // if column and row numbers specified
if( bNoModifiers )
{
CPoint ptNewFocus( htInfo.m_nColNo, htInfo.m_nRowNo );
SelectionSet( ptNewFocus, true, false, false );
FocusSet( ptNewFocus, true, true, false, false );
OnSwDoRedraw();
return;
} // if( bNoModifiers )
ASSERT( bCtrlOnly );
if( (dwSiwStyles&(__EGBS_SFM_COLUMNS|__EGBS_SFM_ROWS)) == 0
|| (! SelectionGetForCell( htInfo.m_nColNo, htInfo.m_nRowNo ) )
|| bReplaceOldSelection
)
return; // processed in WM_LBUTTONDOWN
CPoint ptNewFocus( htInfo.m_nColNo, htInfo.m_nRowNo );
if( ! AutoFocusBottomRightGet() )
FocusSet( ptNewFocus, true, true, false, false );
SelectionSet( ptNewFocus, false, false, true );
return;
} // if column and row numbers specified
} // else from else if( (dwSiwStyles & __EGBS_SFB_MASK) == __EGBS_SFB_FULL_ROWS )
} // if( (htInfo.m_dwAreaFlags & __EGBWA_INNER_CELLS) != 0 )
} // if any selection mode can be tracked
return;
} // if( OnGbwDataDndIsAllowed() && m_eMTT == __EMTT_DATA_DND_STARTING )
if( m_eMTT != __EMTT_NOTHING )
SendMessage( WM_CANCELMODE );
if( OnGbwAnalyzeCellMouseClickEvent(VK_LBUTTON,0,nFlags,point) )
return;
CExtScrollItemWnd::OnLButtonUp(nFlags, point);
}
You can override the
CExtGridBaseWnd::OnGbwAnalyzeCellMouseClickEvent()
virtual method in your
CExtTreeGridWnd
-derived class so you can disable its row double click behavior:
bool CYourCustomTreeGridWnd::OnGbwAnalyzeCellMouseClickEvent(
UINT nChar, // VK_LBUTTON, VK_RBUTTON or VK_MBUTTON only
UINT nRepCnt, // 0 - button up, 1 - single click, 2 - double click, 3 - post single click & begin editing
UINT nFlags, // mouse event flags
CPoint point // mouse pointer in client coordinates
)
{
ASSERT_VALID( this );
ASSERT( 0 <= nRepCnt && nRepCnt <= 3 );
if( nChar == VK_LBUTTON )
{
CExtGridHitTestInfo htInfo( point );
HitTest( htInfo, false, true );
if( htInfo.IsHoverEmpty()
|| (! htInfo.IsValidRect() )
)
return false;
INT nColType = htInfo.GetInnerOuterTypeOfColumn();
INT nRowType = htInfo.GetInnerOuterTypeOfRow();
if( nColType == 0
&& nRowType == 0
)
{
if( ( nRepCnt == 1
&& OnTreeGridQueryColumnOutline( htInfo.m_nColNo )
&& (htInfo.m_dwAreaFlags&__EGBWA_TREE_OUTLINE_AREA) != 0
)
&& (htInfo.m_dwAreaFlags&(__EGBWA_CELL_BUTTON|__EGBWA_CELL_CHECKBOX)) == 0
)
{
HTREEITEM hTreeItem = ItemGetByVisibleRowIndex( htInfo.m_nRowNo );
if( ( nRepCnt == 2
&& hTreeItem != NULL
&& ItemGetChildCount( hTreeItem ) > 0
)
|| (htInfo.m_dwAreaFlags&__EGBWA_TREE_BOX) != 0
)
{
OnTreeGridToggleItemExpandedState(
htInfo.m_nRowNo,
&htInfo
);
return true;
}
}
}
} // if( nChar == VK_LBUTTON && ( nRepCnt == 1 || nRepCnt == 2 ) )
if( nRepCnt == 2 )
return
CExtGridWnd::OnGbwAnalyzeCellMouseClickEvent( // not CExtTreeGridWnd
nChar,
nRepCnt,
nFlags,
point
);
return
CExtTreeGridWnd::OnGbwAnalyzeCellMouseClickEvent(
nChar,
nRepCnt,
nFlags,
point
);
}