void CScrollBarWindow::_OnOwnerWndMoved(BOOL isResized) { isResized; if (IsWindow(_GetWnd()) && IsWindowVisible(_GetWnd())) { _AdjustWindowPos(); } }
void CCandidateWindow::_OnMouseMove(POINT pt) { RECT rcWindow = {0, 0, 0, 0}; _GetClientRect(&rcWindow); RECT rc = {0, 0, 0, 0}; rc.left = rcWindow.left; rc.right = rcWindow.right - GetSystemMetrics(SM_CXVSCROLL) * 2; rc.top = rcWindow.top; rc.bottom = rcWindow.bottom; if (PtInRect(&rc, pt)) { SetCursor(LoadCursor(NULL, IDC_HAND)); return; } SetCursor(LoadCursor(NULL, IDC_ARROW)); if (_pVScrollBarWnd) { _pVScrollBarWnd->_GetClientRect(&rc); MapWindowPoints(_GetWnd(), _pVScrollBarWnd->_GetWnd(), &pt, 1); if (PtInRect(&rc, pt)) { _pVScrollBarWnd->_OnMouseMove(pt); } } }
void CCandidateWindow::_OnLButtonDown(POINT pt) { RECT rcWindow = {0, 0, 0, 0};; _GetClientRect(&rcWindow); int cyLine = _cyRow; UINT candidateListPageCnt = _pIndexRange->Count(); UINT index = 0; int currentPage = 0; if (FAILED(_GetCurrentPage(¤tPage))) { return; } // Hit test on list items index = *_PageIndex.GetAt(currentPage); for (UINT pageCount = 0; (index < _candidateList.Count()) && (pageCount < candidateListPageCnt); index++, pageCount++) { RECT rc = {0, 0, 0, 0}; rc.left = rcWindow.left; rc.right = rcWindow.right - GetSystemMetrics(SM_CXVSCROLL) * 2; rc.top = rcWindow.top + (pageCount * cyLine); rc.bottom = rcWindow.top + ((pageCount + 1) * cyLine); if (PtInRect(&rc, pt) && _pfnCallback) { SetCursor(LoadCursor(NULL, IDC_HAND)); _currentSelection = index; _pfnCallback(_pObj, CAND_ITEM_SELECT); return; } } SetCursor(LoadCursor(NULL, IDC_ARROW)); if (_pVScrollBarWnd) { RECT rc = {0, 0, 0, 0}; _pVScrollBarWnd->_GetClientRect(&rc); MapWindowPoints(_GetWnd(), _pVScrollBarWnd->_GetWnd(), &pt, 1); if (PtInRect(&rc, pt)) { _pVScrollBarWnd->_OnLButtonDown(pt); } } }
void CScrollBarWindow::_AdjustWindowPos() { if (!IsWindow(_GetWnd())) { return; } RECT rc = {0, 0, 0, 0}; CBaseWindow* pParent = _GetParent(); if (pParent == nullptr) { return; } GetWindowRect(pParent->_GetWnd(), &rc); SetWindowPos(_GetWnd(), pParent->_GetWnd(), rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOOWNERZORDER | SWP_NOACTIVATE); }
void CCandidateWindow::_OnLButtonUp(POINT pt) { if (nullptr == _pVScrollBarWnd) { return; } RECT rc = {0, 0, 0, 0}; _pVScrollBarWnd->_GetClientRect(&rc); MapWindowPoints(_GetWnd(), _pVScrollBarWnd->_GetWnd(), &pt, 1); if (_IsCapture()) { _pVScrollBarWnd->_OnLButtonUp(pt); } else if (PtInRect(&rc, pt)) { _pVScrollBarWnd->_OnLButtonUp(pt); } }