/** * @file XTPListCtrlView.cpp * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #include "stdafx.h" #include "Common/XTPTypeId.h" #include "Common/XTPCasting.h" #include "Common/XTPFramework.h" #include "Common/XTPSystemHelpers.h" #include "Common/ScrollBar/XTPScrollBase.h" #include "Common/ScrollBar/XTPScrollBarCtrl.h" #include "Common/ScrollBar/XTPScrollable.h" #include "Controls/Util/XTPControlTheme.h" #include "Controls/Header/XTPHeaderCtrl.h" #include "Controls/List/XTPListBase.h" #include "Controls/List/XTPListCtrlView.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CXTPListView ///////////////////////////////////////////////////////////////////////////// CXTPListView::CXTPListView() { ImplAttach(&GetListCtrl()); } CXTPListView::~CXTPListView() { } IMPLEMENT_DYNCREATE(CXTPListView, CListView) #include "Common/Base/Diagnostic/XTPBeginAfxMap.h" BEGIN_MESSAGE_MAP(CXTPListView, CListView) //{{AFX_MSG_MAP(CXTPListView) ON_LISTCTRL_REFLECT() //}}AFX_MSG_MAP END_MESSAGE_MAP() #include "Common/Base/Diagnostic/XTPEndAfxMap.h" ///////////////////////////////////////////////////////////////////////////// // CXTPListCtrl ///////////////////////////////////////////////////////////////////////////// CXTPListCtrl::CXTPListCtrl() { ImplAttach(this); } CXTPListCtrl::~CXTPListCtrl() { } IMPLEMENT_DYNAMIC(CXTPListCtrl, CListCtrl) #include "Common/Base/Diagnostic/XTPBeginAfxMap.h" BEGIN_MESSAGE_MAP(CXTPListCtrl, CListCtrl) //{{AFX_MSG_MAP(CXTPListCtrl) ON_LISTCTRL_REFLECT() //}}AFX_MSG_MAP END_MESSAGE_MAP() #include "Common/Base/Diagnostic/XTPEndAfxMap.h" ///////////////////////////////////////////////////////////////////////////// static BOOL OnScrollableListCtrlScroll(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult, CWnd* pEmbeddedControl) { UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(pResult); if (NULL == pEmbeddedControl || NULL == lParam) return FALSE; CScrollBar* pScrollBar = DYNAMIC_DOWNCAST(CScrollBar, CWnd::FromHandle(reinterpret_cast(lParam))); if (NULL == pScrollBar) return FALSE; _ASSERTE(NULL != pResult); _ASSERTE(WM_VSCROLL == message || WM_HSCROLL == message); int nBar = (WM_VSCROLL == message ? SB_VERT : SB_HORZ); SCROLLINFO si = { 0 }; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_ALL; pEmbeddedControl->GetScrollInfo(nBar, &si); int nPos = pScrollBar->GetScrollPos(); int nSBCode = LOWORD(wParam); switch (nSBCode) { case SB_TOP: si.nPos = si.nMin; break; case SB_BOTTOM: si.nPos = si.nMax; break; case SB_LINEUP: si.nPos -= 1; break; case SB_LINEDOWN: si.nPos += 1; break; case SB_PAGEUP: si.nPos -= si.nPage; break; case SB_PAGEDOWN: si.nPos += si.nPage; break; case SB_ENDSCROLL: return TRUE; case SB_THUMBPOSITION: case SB_THUMBTRACK: { CRect rcClient; pEmbeddedControl->GetClientRect(&rcClient); SIZE size = { 0, 0 }; if (SB_VERT == nBar) { int cy = (si.nPage == 0 ? static_cast(rcClient.bottom) : static_cast(rcClient.bottom * (si.nMax + 1) / si.nPage)); LONG dy = HIWORD(wParam) - si.nPos; size.cy = cy * dy / (si.nMax + 1); } else { int cx = (si.nPage == 0 ? static_cast(rcClient.right) : static_cast(rcClient.right * (si.nMax + 1) / si.nPage)); LONG dx = HIWORD(wParam) - si.nPos; size.cx = cx * dx / (si.nMax + 1); } CXTPListCtrl* pListControl = DYNAMIC_DOWNCAST(CXTPListCtrl, pEmbeddedControl); if (NULL != pListControl) pListControl->Scroll(size); pEmbeddedControl->GetScrollInfo(nBar, &si); pScrollBar->SetScrollPos(si.nPos); return TRUE; } } pScrollBar->SetScrollPos(nPos); pEmbeddedControl->SendMessage(message, XTPToWPARAM(MAKELONG(nSBCode, nPos)), 0); return TRUE; } BOOL AFXAPI XTPOnScrollableListCtrlWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult, CWnd* pEmbeddedControl) { if (WM_VSCROLL == message || WM_HSCROLL == message) return OnScrollableListCtrlScroll(message, wParam, lParam, pResult, pEmbeddedControl); return FALSE; }