void CSkinComboBox::OnMouseMove(UINT nFlags, CPoint point) { BOOL bRePaint = FALSE; if (!m_bMouseTracking) { TrackMouseLeave(GetSafeHwnd()); m_bMouseTracking = TRUE; m_bHover = TRUE; bRePaint = TRUE; } if (VerdictOverButton(point)) { if (!m_bArrowHover) { m_bArrowHover = TRUE; bRePaint = TRUE; } } else { if (m_bArrowHover) { m_bArrowHover = FALSE; bRePaint = TRUE; } } if (bRePaint) RedrawWindow(NULL,NULL,RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW); __super::OnMouseMove(nFlags, point); }
void CSkinListBox::OnMouseMove(UINT nFlags, CPoint point) { if (!m_bMouseTracking) { TrackMouseLeave(GetSafeHwnd()); m_bMouseTracking = TRUE; Invalidate(FALSE); } CRect rcItem(0,0,0,0); //保存旧状态,为了防止在同一个节点下因过多的刷新消耗cpu资源 static int nOldIndex = -1; for (int i =0; i<GetCount(); i++) { GetItemRect(i, &rcItem); if(rcItem.PtInRect(point)) { if( m_nHovenItem != i ) Invalidate(FALSE); m_nHovenItem = i; break; } } __super::OnMouseMove(nFlags, point); }
void CEasySkinSliderCtrl::OnMouseMove(UINT nFlags, CPoint point) { if( m_bDragging ) { int nMax = 0; int nMin = 0; GetRange(nMin,nMax); int nPos = 0; if ( GetStyle() & TBS_VERT ) nPos = (nMax - nMin)*(point.y)/m_rcChannelRect.Height(); else nPos = (nMax - nMin)*(point.x)/m_rcChannelRect.Width(); SetPos(nPos); RedrawWindow(NULL,NULL,RDW_FRAME|RDW_INVALIDATE|RDW_ERASE|RDW_ERASENOW); } //按钮事件 if ( PtInRect(m_rcThumRect,point) && !m_bMouseTracking ) { TrackMouseLeave(GetSafeHwnd()); m_bMouseTracking = TRUE; m_bHover = TRUE; RedrawWindow(NULL,NULL,RDW_FRAME|RDW_INVALIDATE|RDW_ERASE|RDW_ERASENOW); } __super::OnMouseMove(nFlags, point); }
void CSkinTabCtrl::OnMouseMove(UINT nFlags, CPoint point) { if (!m_bMouseTracking) { TrackMouseLeave(GetSafeHwnd()); m_bMouseTracking = TRUE; } int nIndex; nIndex = HitTest(point); if (nIndex != -1) { CSkinTabCtrlItem * lpItem = GetItemByIndex(nIndex); if (lpItem != NULL) { CRect rcItem; GetItemRectByIndex(nIndex, rcItem); if (nIndex != m_nHoverIndex && lpItem->m_strToolTipText.GetLength() > 0) { if (!m_ToolTipCtrl.GetSafeHwnd()) { m_ToolTipCtrl.Create(this); m_ToolTipCtrl.SetMaxTipWidth(200); } if (m_ToolTipCtrl.GetSafeHwnd()) { if (m_ToolTipCtrl.GetToolCount() <= 0) { m_ToolTipCtrl.Activate(TRUE); m_ToolTipCtrl.AddTool(this, lpItem->m_strToolTipText.GetBuffer(), &rcItem, 1); } else { m_ToolTipCtrl.Activate(TRUE); m_ToolTipCtrl.UpdateTipText(lpItem->m_strToolTipText.GetBuffer(), this, 1); m_ToolTipCtrl.SetToolRect(this, 1, &rcItem); } } } } } if (nIndex != m_nHoverIndex) { m_nHoverIndex = nIndex; Invalidate(); } __super::OnMouseMove(nFlags, point); }
void CSkinComboBox_Edit::OnMouseMove(UINT nFlags, CPoint point) { if (!m_bMouseTracking) { m_bMouseTracking = TRUE; TrackMouseLeave(GetSafeHwnd()); if (::IsWindow(m_hOwnerWnd)) ::SendMessage(m_hOwnerWnd, WM_CBO_EDIT_MOUSE_HOVER, 0, 0); } __super::OnMouseMove(nFlags, point); }
void CMyEdit::OnMouseMove(UINT nFlags, CPoint point) { if (!m_bMouseTracking) { TrackMouseLeave(GetSafeHwnd()); m_bMouseTracking = TRUE; m_bHover = TRUE; RedrawWindow(NULL,NULL,RDW_FRAME|RDW_INVALIDATE|RDW_ERASE|RDW_ERASENOW); } CEdit::OnMouseMove(nFlags, point); }
void CSkinSliderCtrl::OnMouseMove(UINT nFlags, CPoint point) { if( m_bDragging ) { int nMax = 0; int nMin = 0; GetRange(nMin,nMax); int nPos = 0; if ( GetStyle() & TBS_VERT ) nPos = (nMax - nMin)*(point.y)/m_rcChannelRect.Height(); else nPos = (nMax - nMin)*(point.x)/m_rcChannelRect.Width(); SetPos(nPos); RedrawWindow(NULL,NULL,RDW_FRAME|RDW_INVALIDATE|RDW_ERASE|RDW_ERASENOW); if (GetParent() && ::IsWindow(GetParent()->m_hWnd)) { GetParent()->SendMessage(WM_HSCROLL, MAKELONG(SB_THUMBTRACK, GetPos()), (LPARAM)m_hWnd); } } //按钮事件 if ( PtInRect(m_rcThumRect,point) && !m_bMouseTracking ) { TrackMouseLeave(GetSafeHwnd()); m_bMouseTracking = TRUE; m_bHover = TRUE; RedrawWindow(NULL,NULL,RDW_FRAME|RDW_INVALIDATE|RDW_ERASE|RDW_ERASENOW); } __super::OnMouseMove(nFlags, point); }
static LRESULT CALLBACK TabBarProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { PAINTSTRUCT ps; HDC hdc; int index; LPTCITEM tcs; UNUSED(uIdSubclass); UNUSED(dwRefData); TabPainter* tab = (TabPainter*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (WM_NCDESTROY == msg) { RemoveWindowSubclass(GetParent(hwnd), TabBarParentProc, 0); RemoveWindowSubclass(hwnd, TabBarProc, 0); return DefSubclassProc(hwnd, msg, wp, lp); } switch (msg) { case WM_DESTROY: delete tab; SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)0); break; case TCM_INSERTITEM: index = (int)wp; tcs = (LPTCITEM)lp; CrashIf(!(TCIF_TEXT & tcs->mask)); tab->Insert(index, tcs->pszText); if (index <= tab->selectedTabIdx) tab->selectedTabIdx++; tab->xClicked = -1; InvalidateRgn(hwnd, nullptr, FALSE); UpdateWindow(hwnd); break; case TCM_SETITEM: index = (int)wp; tcs = (LPTCITEM)lp; if (TCIF_TEXT & tcs->mask) { if (tab->Set(index, tcs->pszText)) { tab->Invalidate(index); } } break; case TCM_DELETEITEM: index = (int)wp; if (tab->Delete(index)) { if (index < tab->selectedTabIdx) { tab->selectedTabIdx--; } else if (index == tab->selectedTabIdx) { tab->selectedTabIdx = -1; } tab->xClicked = -1; if (tab->Count()) { InvalidateRgn(hwnd, nullptr, FALSE); UpdateWindow(hwnd); } } break; case TCM_DELETEALLITEMS: tab->DeleteAll(); tab->selectedTabIdx = -1; tab->highlighted = -1; tab->xClicked = -1; tab->xHighlighted = -1; break; case TCM_SETITEMSIZE: if (tab->Reshape(LOWORD(lp), HIWORD(lp))) { tab->xClicked = -1; if (tab->Count()) { InvalidateRgn(hwnd, nullptr, FALSE); UpdateWindow(hwnd); } } break; case TCM_GETCURSEL: return tab->selectedTabIdx; case TCM_SETCURSEL: { index = (int)wp; if (index >= tab->Count()) { return -1; } int previous = tab->selectedTabIdx; if (index != tab->selectedTabIdx) { tab->Invalidate(tab->selectedTabIdx); tab->Invalidate(index); tab->selectedTabIdx = index; UpdateWindow(hwnd); } return previous; } case WM_NCHITTEST: { if (!tab->inTitlebar || hwnd == GetCapture()) { return HTCLIENT; } POINT pt = {GET_X_LPARAM(lp), GET_Y_LPARAM(lp)}; ScreenToClient(hwnd, &pt); if (-1 != tab->IndexFromPoint(pt.x, pt.y)) { return HTCLIENT; } } return HTTRANSPARENT; case WM_MOUSELEAVE: PostMessage(hwnd, WM_MOUSEMOVE, 0xFF, 0); return 0; case WM_MOUSEMOVE: { tab->mouseCoordinates = lp; if (0xff != wp) { TrackMouseLeave(hwnd); } bool inX = false; int hl = wp == 0xFF ? -1 : tab->IndexFromPoint(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), &inX); if (tab->isDragging && hl == -1) { // preserve the highlighted tab if it's dragged outside the tabs' area hl = tab->highlighted; } if (tab->highlighted != hl) { if (tab->isDragging) { // send notification if the highlighted tab is dragged over another WindowInfo* win = FindWindowInfoByHwnd(hwnd); int tabNo = tab->highlighted; uitask::Post([=] { TabNotification(win, T_DRAG, tabNo, hl); }); } tab->Invalidate(hl); tab->Invalidate(tab->highlighted); tab->highlighted = hl; } int xHl = inX && !tab->isDragging ? hl : -1; if (tab->xHighlighted != xHl) { tab->Invalidate(xHl); tab->Invalidate(tab->xHighlighted); tab->xHighlighted = xHl; } if (!inX) tab->xClicked = -1; } return 0; case WM_LBUTTONDOWN: bool inX; tab->nextTab = tab->IndexFromPoint(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), &inX); if (inX) { // send request to close the tab WindowInfo* win = FindWindowInfoByHwnd(hwnd); int next = tab->nextTab; uitask::Post([=] { TabNotification(win, T_CLOSING, next, -1); }); } else if (tab->nextTab != -1) { if (tab->nextTab != tab->selectedTabIdx) { // send request to select tab WindowInfo* win = FindWindowInfoByHwnd(hwnd); uitask::Post([=] { TabNotification(win, TCN_SELCHANGING, -1, -1); }); } tab->isDragging = true; SetCapture(hwnd); } return 0; case WM_LBUTTONUP: if (tab->xClicked != -1) { // send notification that the tab is closed WindowInfo* win = FindWindowInfoByHwnd(hwnd); int clicked = tab->xClicked; uitask::Post([=] { TabNotification(win, T_CLOSE, clicked, -1); }); tab->Invalidate(clicked); tab->xClicked = -1; } if (tab->isDragging) { tab->isDragging = false; ReleaseCapture(); } return 0; case WM_MBUTTONDOWN: // middle-clicking unconditionally closes the tab { tab->nextTab = tab->IndexFromPoint(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)); // send request to close the tab WindowInfo* win = FindWindowInfoByHwnd(hwnd); int next = tab->nextTab; uitask::Post([=] { TabNotification(win, T_CLOSING, next, -1); }); } return 0; case WM_MBUTTONUP: if (tab->xClicked != -1) { // send notification that the tab is closed WindowInfo* win = FindWindowInfoByHwnd(hwnd); int clicked = tab->xClicked; uitask::Post([=] { TabNotification(win, T_CLOSE, clicked, -1); }); tab->Invalidate(clicked); tab->xClicked = -1; } return 0; case WM_ERASEBKGND: return TRUE; case WM_PAINT: { RECT rc; GetUpdateRect(hwnd, &rc, FALSE); // TODO: when is wp != nullptr? hdc = wp ? (HDC)wp : BeginPaint(hwnd, &ps); DoubleBuffer buffer(hwnd, RectI::FromRECT(rc)); tab->Paint(buffer.GetDC(), rc); buffer.Flush(hdc); ValidateRect(hwnd, nullptr); if (!wp) EndPaint(hwnd, &ps); return 0; } case WM_SIZE: { WindowInfo* win = FindWindowInfoByHwnd(hwnd); if (win) UpdateTabWidth(win); } break; } return DefSubclassProc(hwnd, msg, wp, lp); }
void CSkinToolBar::OnMouseMove(UINT nFlags, CPoint point) { if (m_nPressIndex != -1) return; if (!m_bMouseTracking) { TrackMouseLeave(GetSafeHwnd()); m_bMouseTracking = TRUE; } int nIndex; BOOL bHoverLorR = FALSE; nIndex = HitTest(point); if (nIndex != -1) { CSkinToolBarItem * lpItem = GetItemByIndex(nIndex); if (lpItem != NULL) { CRect rcItem; GetItemRectByIndex(nIndex, rcItem); if (lpItem->m_dwStyle & STBI_STYLE_DROPDOWN || lpItem->m_dwStyle & STBI_STYLE_WHOLEDROPDOWN) { CRect rcLeft(rcItem); rcLeft.right = rcLeft.left + lpItem->m_nLeftWidth; CRect rcRight(rcItem); rcRight.left += lpItem->m_nLeftWidth; rcRight.right = rcRight.left + lpItem->m_nRightWidth; if (rcLeft.PtInRect(point)) bHoverLorR = TRUE; if (rcRight.PtInRect(point)) bHoverLorR = FALSE; } if (nIndex != m_nHoverIndex && lpItem->m_strToolTipText.GetLength() > 0) { if (!m_ToolTipCtrl.GetSafeHwnd()) { m_ToolTipCtrl.Create(this); m_ToolTipCtrl.SetMaxTipWidth(200); } if (m_ToolTipCtrl.GetSafeHwnd()) { if (m_ToolTipCtrl.GetToolCount() <= 0) { m_ToolTipCtrl.Activate(TRUE); m_ToolTipCtrl.AddTool(this, lpItem->m_strToolTipText.GetBuffer(), &rcItem, 1); } else { m_ToolTipCtrl.Activate(TRUE); m_ToolTipCtrl.UpdateTipText(lpItem->m_strToolTipText.GetBuffer(), this, 1); m_ToolTipCtrl.SetToolRect(this, 1, &rcItem); } } } } } if (nIndex != m_nHoverIndex || m_bHoverLorR != bHoverLorR) { m_nHoverIndex = nIndex; m_bHoverLorR = bHoverLorR; Invalidate(FALSE); } __super::OnMouseMove(nFlags, point); }