void CTravelTab::OnRButtonDown(UINT nFlags, CPoint point) { ClientToScreen(&point); CRect rect; m_TravelMap.GetWindowRect(&rect); if ( rect.PtInRect(point) ) { xscroll = point.x-rect.left; yscroll = point.y-rect.top; } else { ScreenToClient(&point); CDockingPage::OnRButtonDown(nFlags, point); } }
int CAxRectTracker::HitTest(CPoint point) const { TrackerHit hitResult = hitNothing; CRect rectTrue; GetTrueRect(&rectTrue); ASSERT(rectTrue.left <= rectTrue.right); ASSERT(rectTrue.top <= rectTrue.bottom); if (rectTrue.PtInRect(point)) { if ((m_nStyle & (resizeInside|resizeOutside)) != 0) hitResult = (TrackerHit)HitTestHandles(point); else hitResult = hitMiddle; } return hitResult; }
int CWndRepairItemCtrl::HitTest( CPoint point ) { CRect rect = GetClientRect(); int nWidth = rect.Width() / 32; int nHeight = rect.Height() / 35; for( int i = 0; i < MAX_VENDITEM; i++ ) { int x = i % 5; int y = i / 5; rect.SetRect( x * 32, y * 32, x * 32 + 32, y * 32 + 32 ); if( rect.PtInRect( point ) ) return i; } return -1; }
int CPlayerToolBar::getHitButtonIdx(CPoint point) { int hit = -1; CRect r; for (int i = 0, j = GetToolBarCtrl().GetButtonCount(); i < j; i++) { GetItemRect(i, r); if (r.PtInRect(point)) { hit = i; break; } } return hit; }
void COXNotesEditView::OnLButtonDblClk(UINT nFlags, CPoint point) { CRect rct; GetNotesRect(&rct); if (rct.PtInRect(point)) { int n=HIWORD(GetEditCtrl().CharFromPos(point)); int nChar=GetEditCtrl().LineIndex(n); if (IsMarked(nChar)) RemoveBookmarks(nChar,nChar); else SetBookmark(nChar); } CEditView::OnLButtonDblClk(nFlags, point); }
void CGuiSliderCtrl::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if (bSelected==TRUE) return; CRect rc; GetClientRect(&rc); if (rc.PtInRect(point)) { bSelected=TRUE; Invalidate(); UpdateWindow(); SetTimer(1,100,NULL); } CSliderCtrl::OnMouseMove(nFlags, point); }
void CSubtitleDlDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR; if(lpnmlv->iItem >= 0) { CRect r; m_list.GetItemRect(lpnmlv->iItem, r, LVIR_ICON); if(r.PtInRect(lpnmlv->ptAction)) { SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem)&1) == 0 ? 1 : 0); } } *pResult = 0; }
void CNCaptureView::OnLButtonDown(UINT nFlags, CPoint point) { if (m_pImage) { CRect rcDrawTarget = m_rcDrawTarget; rcDrawTarget.OffsetRect(-rcDrawTarget.TopLeft()); CPoint ptLogical = point; ClientToDoc(&ptLogical); if (rcDrawTarget.PtInRect(ptLogical)) { CDrawCanvas<CNCaptureView>::OnLButtonDown(nFlags, point); _SetSelectRectClipInfo(point); } } SetMsgHandled(FALSE); }
LRESULT CSizingControlBarG::OnNcHitTest(CPoint point) { CRect rcBar; GetWindowRect(rcBar); UINT nRet = baseCSizingControlBarG::OnNcHitTest(point); if (nRet != HTCLIENT) return nRet; CRect rc = m_biHide.GetRect(); rc.OffsetRect(rcBar.TopLeft()); if (rc.PtInRect(point)) return HTCLOSE; return HTCLIENT; }
void CToolTips::RelayEvent( LPMSG lpMsg, CWnd * dlgWnd ) { if(dlgWnd && ((lpMsg->message == WM_MOUSEMOVE) || (lpMsg->message == WM_NCMOUSEMOVE)) && (lpMsg->hwnd == dlgWnd->m_hWnd)) { // allow tooltips for disabled controls CRect rect; POINT pt; pt.x = LOWORD(lpMsg->lParam); pt.y = HIWORD(lpMsg->lParam); for (auto it = toolTextMap.cbegin(); it != toolTextMap.cend(); ++it) { CWnd * pWndCtrl = dlgWnd->GetDlgItem(it->first); pWndCtrl->GetWindowRect(&rect); if (lpMsg->message == WM_MOUSEMOVE) dlgWnd->ScreenToClient(&rect); if(rect.PtInRect(pt) ) { // save the original parameters HWND origHwnd = lpMsg->hwnd; LPARAM origLParam = lpMsg->lParam; // translate and relay the mouse move message to // the tooltip control as if they were sent // by the disabled control lpMsg->hwnd = pWndCtrl->m_hWnd; if (lpMsg->message == WM_MOUSEMOVE) dlgWnd->ClientToScreen(&pt); pWndCtrl->ScreenToClient(&pt); lpMsg->lParam = MAKELPARAM(pt.x, pt.y); __super::RelayEvent(lpMsg); // restore the original parameters lpMsg->hwnd = origHwnd; lpMsg->lParam = origLParam; return; } } } // Let the ToolTip process this message. __super::RelayEvent(lpMsg); }
int CListCtrlEx::HitTestEx (CPoint& Point, int* pColumn) { int ColumnNum = 0; int Row = HitTest (Point, NULL); if (pColumn) *pColumn = 0; // Make sure that the ListView is in LVS_REPORT if ((GetWindowLong (m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT) return Row; // Get the top and bottom row visible Row = GetTopIndex(); int Bottom = Row + GetCountPerPage(); if (Bottom > GetItemCount()) Bottom = GetItemCount(); // Get the number of columns CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem(0); int nColumnCount = pHeader->GetItemCount(); // Loop through the visible rows for(; Row <= Bottom; Row++) { // Get bounding rect of item and check whether point falls in it. CRect Rect; GetItemRect (Row, &Rect, LVIR_BOUNDS); if (Rect.PtInRect (Point)) { // Now find the column for (ColumnNum = 0; ColumnNum < nColumnCount; ColumnNum++) { int ColWidth = GetColumnWidth (ColumnNum); if (Point.x >= Rect.left && Point.x <= (Rect.left + ColWidth)) { if (pColumn) *pColumn = ColumnNum; return Row; } Rect.left += ColWidth; } } } return -1; }
BOOL CWndShopCtrl::OnDropIcon( LPSHORTCUT pShortcut, CPoint point ) { CWndBase* pWndFrame = pShortcut->m_pFromWnd->GetFrameWnd(); if( pWndFrame->GetWndId() != APP_SHOP_ ) return FALSE; if( pShortcut->m_dwShortcut == SHORTCUT_ITEM ) { CItemElem* pItemElem = (CItemElem*)pShortcut->m_dwData; DWORD nTempCost = 0; if( m_nTabType == 0) { nTempCost += pItemElem->GetCost(); nTempCost = static_cast< int >( static_cast< float >( nTempCost ) * prj.m_fShopBuyRate ); if(CTax::GetInstance()->IsApplyTaxRate( g_pPlayer, pItemElem )) nTempCost += ( static_cast<DWORD>(nTempCost * CTax::GetInstance()->GetPurchaseTaxRate( g_pPlayer )) ); } else if( m_nTabType == 1 || m_nTabType == 2 ) nTempCost += pItemElem->GetChipCost(); nTempCost = (int)((float)nTempCost * prj.m_fShopCost ); if( pItemElem && pItemElem->m_dwItemId == II_SYS_SYS_SCR_PERIN ) nTempCost = PERIN_VALUE; if( nTempCost > INT_MAX ) return FALSE; for( int i = 0; i < MAX_CART; i++ ) { int x = i % 6; int y = i / 6; CRect rectHittest = CRect( x * 35, y * 35 + 3, x * 35 + 35, y * 35 + 35 + 3); if( rectHittest.PtInRect( point ) ) { m_nLastPoint = i; break; } } CWndBase* pParent = (CWndBase*)GetParentWnd(); pParent->OnChildNotify( WIN_ITEMDROP, m_nIdWnd, (LRESULT*)pShortcut ); return TRUE; } return FALSE; }
BOOL CCeWatchDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (pWnd != NULL && IsWindow(m_ToolTipCtrl.GetSafeHwnd())) { POINT pt; CRect rc; ::GetCursorPos(&pt); for (int ii = 0; ii < sizeof(m_ToolWndArray)/sizeof(CWnd*); ii++) { if (m_ToolWndArray[ii] != NULL && IsWindow(m_ToolWndArray[ii]->GetSafeHwnd())) { m_ToolWndArray[ii]->GetWindowRect(rc); if (rc.PtInRect(pt)) { m_ToolWndArray[ii]->ScreenToClient(&pt); MSG msg; switch(message) { case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: msg.message = message; break; default: msg.message = WM_MOUSEMOVE; break; } msg.hwnd = m_ToolWndArray[ii]->m_hWnd; msg.wParam = 0; msg.lParam = MAKELPARAM(pt.x, pt.y); msg.time = 0; msg.pt = pt; m_ToolTipCtrl.RelayEvent(&msg); break; } } } } return CDialog::OnSetCursor(pWnd, nHitTest, message); }
void CButtonST::OnMouseMove(UINT nFlags, CPoint point) { CWnd* pWnd; // Finestra attiva CWnd* pParent; // Finestra che contiene il bottone CButton::OnMouseMove(nFlags, point); // If the mouse enter the button with the left button pressed // then do nothing if (nFlags & MK_LBUTTON && m_MouseOnButton == FALSE) return; // If our button is not flat then do nothing if (m_bIsFlat == FALSE) return; pWnd = GetActiveWindow(); pParent = GetOwner(); if ((GetCapture() != this) && ( #ifndef ST_LIKEIE pWnd != NULL && #endif pParent != NULL)) { m_MouseOnButton = TRUE; //SetFocus(); // Thanks Ralph! SetCapture(); Invalidate(); } else { CRect rc; GetClientRect(&rc); if (!rc.PtInRect(point)) { // Redraw only if mouse goes out if (m_MouseOnButton == TRUE) { m_MouseOnButton = FALSE; Invalidate(); } // If user is NOT pressing left button then release capture! if (!(nFlags & MK_LBUTTON)) ReleaseCapture(); } } } // End of OnMouseMove
void DesuraProgress::OnMouseMove(UINT nFlags, CPoint point) { bool old = m_bMouseOver; CRect rect = getCancelRect(); m_bMouseOver = rect.PtInRect(point); if (old != m_bMouseOver) refresh(); if (m_bDragging) { CPoint pos = point - m_StartPoint; ClientToScreen(pos); GetParent()->SetWindowPos(pos.x-4, pos.y-26, 0, 0, SWP_NOSIZE); } }
void COXStatusBar::OnLButtonDblClk(UINT nFlags, CPoint point) { UNREFERENCED_PARAMETER(nFlags); CRect PaneRect; // first walk through to calculate extra space for (int i=0; i < m_nCount; i++) { GetItemRect(i, PaneRect); if (PaneRect.PtInRect(point) != 0) { GetParent()->SendMessage(WM_STAT_DBLCLICK, (WPARAM)GetItemID(i)); break; } } }
void CPlayerSeekBar::OnLButtonDown(UINT nFlags, CPoint point) { CRect clientRect; GetClientRect(&clientRect); if (m_bEnabled && m_bHasDuration && clientRect.PtInRect(point)) { m_bHovered = false; SetCapture(); MoveThumb(point); VERIFY(SetTimer(TIMER_HOVER_CAPTURED, HOVER_CAPTURED_TIMEOUT, nullptr)); } else { auto pFrame = AfxGetMainFrame(); if (!pFrame->m_fFullScreen) { MapWindowPoints(pFrame, &point, 1); pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y)); } } }
void CWndBlessingCancel::OnLButtonDblClk( UINT nFlags, CPoint point ) { if(!m_pItemElem) return; CRect rect; LPWNDCTRL wndCtrl = GetWndCtrl( WIDC_CHANGE ); rect = wndCtrl->rect; if( rect.PtInRect( point ) ) { m_pItemElem->SetExtra(0); CWndButton* pButton = (CWndButton*)GetDlgItem(WIDC_START); pButton->EnableWindow(FALSE); m_pItemElem = NULL; m_pEItemProp = NULL; m_pTexture = NULL; } }
bool CComboListCtrl::HitTestEx(CPoint &obPoint, int* pRowIndex, int* pColumnIndex) const { if (!pRowIndex || !pColumnIndex) { return false; } // Get the row index *pRowIndex = HitTest(obPoint, NULL); if (pColumnIndex) { *pColumnIndex = 0; } // Make sure that the ListView is in LVS_REPORT if ((GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT) { return false; } // Get the number of columns CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0); int iColumnCount = pHeader->GetItemCount(); // Get bounding rect of item and check whether obPoint falls in it. CRect obCellRect; GetItemRect(*pRowIndex, &obCellRect, LVIR_BOUNDS); if (obCellRect.PtInRect(obPoint)) { // Now find the column for (*pColumnIndex = 0; *pColumnIndex < iColumnCount; (*pColumnIndex)++) { int iColWidth = GetColumnWidth(*pColumnIndex); if (obPoint.x >= obCellRect.left && obPoint.x <= (obCellRect.left + iColWidth)) { return true; } obCellRect.left += iColWidth; } } return false; }
// // OnNcHitTest // Handle mouse over the gripper // // Credit: Tommy Svensson // LRESULT CResizingDialog::OnNcHitTest(CPoint point) { UINT ht = CDialog::OnNcHitTest(point); if(ht==HTCLIENT && m_bDrawGripper) { CRect rc; GetWindowRect( rc ); rc.left = rc.right-GetSystemMetrics(SM_CXHSCROLL); rc.top = rc.bottom-GetSystemMetrics(SM_CYVSCROLL); if(rc.PtInRect(point)) { ht = HTBOTTOMRIGHT; } } return ht; }
BOOL CRemoteSettingsPage::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { CPoint point; GetCursorPos( &point ); CRect rect; m_wndURL.GetWindowRect( &rect ); if ( rect.PtInRect( point ) && m_wndURL.IsWindowEnabled() ) { SetCursor( AfxGetApp()->LoadCursor( IDC_HAND ) ); return TRUE; } else { return CSettingsPage::OnSetCursor( pWnd, nHitTest, message ); } }
void CDropListBox::OnMouseMove(UINT nFlags, CPoint point) { // // Is mouse within listbox CRect rcClient; GetClientRect( rcClient ); if( !rcClient.PtInRect( point ) ) { ReleaseCapture(); GetParent()->SendMessage( WM_VRC_SETCAPTURE ); } // // Set selection item under mouse int nPos = point.y / GetItemHeight(0) + GetTopIndex(); PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(nPos); if( (DWORD)pItem != -1 ) { if( GetCurSel() != nPos && !pItem->bDisabled ) { SetCurSel( nPos ); } } // // Check if we have autoscrolled if( m_nLastTopIdx != GetTopIndex() ) { int nDiff = m_nLastTopIdx - GetTopIndex(); m_nLastTopIdx = GetTopIndex(); SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); if( m_pScroll->GetScrollInfo( &info, SIF_ALL|SIF_DISABLENOSCROLL ) ) { info.nPos = m_nLastTopIdx; m_pScroll->SetScrollInfo( &info ); } } // OutputDebugString( "DropListBox MouseMove\n" ); CListBox::OnMouseMove(nFlags, point); }
/////////////////////////////////////////////////////////////////////////////// // OnTimer void CXTipListBox::OnTimer(UINT nIDEvent) { CPoint point; ::GetCursorPos(&point); ScreenToClient(&point); CRect rectClient; GetClientRect(&rectClient); DWORD dwStyle = GetStyle(); if ((!rectClient.PtInRect(point)) || ((dwStyle & WS_VISIBLE) == 0)) { TRACE(_T("not in listbox =====\n")); KillTimer(nIDEvent); ::SendMessage(m_hWndToolTip, TTM_TRACKACTIVATE, FALSE, (LPARAM)(LPTOOLINFO) &m_ToolInfo); } }
UINT CAboutDlg::OnNcHitTest(CPoint point) { CRect rectClient; CPoint ptClient(point); GetClientRect(rectClient); ScreenToClient(&ptClient); if(rectClient.PtInRect(ptClient)) { return (HTCLIENT); } else { return (CWnd::OnNcHitTest(point)); } // return CDialog::OnNcHitTest(point); }
void CHyperLink::OnTimer(UINT) { CPoint point; ::GetCursorPos(&point); CRect rect; GetWindowRect(&rect); if (rect.PtInRect(point)) // Cursor is currently over control { m_bOverControl = TRUE; } else { m_bOverControl = FALSE; } RedrawWindow(); }
void CBarButton::OnLButtonUp(UINT nFlags, CPoint point) { CRect rect; GetClientRect(&rect); if (m_bLButtonDown && rect.PtInRect(point) && m_hNotify && m_uMsg) ::PostMessage(m_hNotify, m_uMsg, GetDlgCtrlID(), 0); m_bLButtonDown = FALSE; Repaint(); CButton::OnLButtonUp(nFlags, point); }
UINT CSkinDialog::OnNcHitTest(CPoint point) { // TODO: Add your message handler code here and/or call default CRect rcWindow; GetWindowRect(&rcWindow); CRect rcBtn; rcBtn.left = rcWindow.left + m_mapRect["BorderLeft"].Width; rcBtn.top = rcWindow.top + 1; rcBtn.right = rcWindow.right - 1; rcBtn.bottom = rcWindow.top + m_mapRect["TitleLeft"].Height; if(rcBtn.PtInRect(point)) return HTCAPTION; return CXTPDialog::OnNcHitTest(point); }
int CListCtrlEx::CellRectFromPoint(CPoint& point, CRect* pRectCell, int* pCol) const { if((::GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT ) return -1; int nRow = GetTopIndex(); int nBottom = nRow + GetCountPerPage(); if(nBottom > GetItemCount()) nBottom = GetItemCount(); CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0); int nColumnCount = pHeader->GetItemCount(); for(; nRow <= nBottom; nRow++) { CRect rect; GetItemRect(nRow, &rect, LVIR_BOUNDS); if(rect.PtInRect(point)) { for(int nColumn = 0; nColumn < nColumnCount; nColumn++) { int nColWidth = GetColumnWidth(nColumn); if(point.x >= rect.left && point.x <= (rect.left + nColWidth)) { CRect rectClient; GetClientRect(&rectClient); if(pCol) *pCol = nColumn; rect.right = rect.left + nColWidth; if(rect.right > rectClient.right) rect.right = rectClient.right; *pRectCell = rect; return nRow; } rect.left += nColWidth; } } } return -1; }
CString CToolbarHelper::GetTip(UINT nID, LPPOINT pPoint) const { if (!nID) return ""; // separator // are we over the dropbutton? BOOL bOverDropBtn = FALSE; if (pPoint) { CSize sizeBtn(m_pToolbar->GetToolBarCtrl().GetButtonSize()); CRect rButton; m_pToolbar->GetToolBarCtrl().GetRect(nID, rButton); rButton.left += sizeBtn.cx; if (rButton.PtInRect(*pPoint)) bOverDropBtn = TRUE; } CString sTip; // do we have a mapping for this THButton dm = { 0 }; if (m_mapTHButtons.Lookup(nID, dm)) { if (!bOverDropBtn) { // try the default item first if (dm.nDefCmdID && IsCmdEnabled(dm.nDefCmdID)/* && (dm.nDefCmdID != nID)*/) { sTip = GetTip(dm.nDefCmdID); if (!sTip.IsEmpty()) return sTip; } } // try override tip if (lstrlen(dm.szTip)) return dm.szTip; } return GetTip(nID); }
void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point) { CSkinDialog::OnLButtonUp( nFlags, point ); CRect rc; m_wndWeb.GetWindowRect( &rc ); ScreenToClient( &rc ); if ( rc.PtInRect( point ) ) { const CString strWebSite(WEB_SITE_T); ShellExecute( GetSafeHwnd(), _T("open"), strWebSite + _T("?Version=") + theApp.m_sVersion, NULL, NULL, SW_SHOWNORMAL ); } }