Exemple #1
0
CWnd *CCSHCommon::WndFromPoint(CWnd *pDialog,CWnd* pWnd,CPoint pt) 
{
  CWnd *rc=NULL;
  CPoint ptClient(pt);
  pDialog->ScreenToClient(&ptClient);
  if(pWnd==pDialog){
    // The pWnd argument is the dialog itself for disabled controls
    // Can't use ChildWindowFromPoint() - may return an enclosing group box
    for(CWnd *p=pDialog->GetWindow(GW_CHILD);p;p=p->GetWindow(GW_HWNDNEXT)){
      TCHAR buf[256];
      if(::GetClassName(p->m_hWnd,buf,sizeof buf)){
        if(0==_tcscmp(buf,_T("STATIC"))){
          continue;
        } else if(0==_tcscmp(buf,_T("Button")) && p->GetStyle()&BS_GROUPBOX) {
          continue;
        } else {
          CRect rect;
          p->GetWindowRect(rect);
          if(rect.PtInRect(pt)){
            rc=p;
            break;
          }
        }
      }
    }
  } else {
    rc=pWnd;
  }
  return rc;
}
void CXTPSkinObjectFrame::OnNcRButtonUp(UINT nHitTest, CPoint point)
{
    CPoint ptClient(point);
    ScreenToFrame(&ptClient);

    for (int i = 0; i < 2; i++)
    {
        XTP_SKINSCROLLBARPOSINFO* pSBInfo = &m_spi[i];
        int ht = HitTestScrollBar(pSBInfo, ptClient);

        if (ht != HTNOWHERE)
        {
            m_bLockFrameDraw++;
            RECT rc = CXTPWindowRect(this);
            SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
            m_bLockFrameDraw--;

            SendMessage(WM_CONTEXTMENU, (WPARAM)m_hWnd, MAKELPARAM(point.x, point.y));

            RefreshFrameStyle();
            return;
        }
    }

    CXTPSkinObject::OnNcRButtonDown(nHitTest, point);
}
Exemple #3
0
void CWebCtrl::EnterMenu(POINT* pPoint)
{
	if ( m_pThis != NULL )
	{
		SetWindowLongPtr( m_pThis->m_hWndThis, GWLP_WNDPROC, (LONG_PTR)m_pThis->m_pWndProc );
		m_pThis = NULL;
	}

	if ( pPoint == NULL || m_pMenu == NULL ) return;

	CPoint ptScreen( *pPoint );
	ptScreen.Offset( 2, 2 );

	CWnd* pChild = this;
	for ( ;; )
	{
		CPoint ptClient( ptScreen );
		pChild->ScreenToClient( &ptClient );
		CWnd* pNext = pChild->ChildWindowFromPoint( ptClient, CWP_ALL );
		if ( pNext == NULL || pNext == pChild ) break;
		pChild = pNext;
	}

	TCHAR szClass[128];
	GetClassName( *pChild, szClass, 128 );
	if ( _tcsistr( szClass, _T("Internet Explorer") ) == NULL ) return;

	m_pThis = this;
	m_hWndThis = pChild->GetSafeHwnd();
	m_pWndProc = (WNDPROC)(LONG_PTR)GetWindowLongPtr( m_hWndThis, GWLP_WNDPROC );
	SetWindowLongPtr( m_hWndThis, GWLP_WNDPROC, (LONG_PTR)&WebWndProc );
}
void CXTPSkinObjectFrame::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
    if (m_pButtonHot)
    {
        TrackCaptionButton();
    }

    CPoint ptClient(point);
    ScreenToFrame(&ptClient);

    for (int i = 0; i < 2; i++)
    {
        XTP_SKINSCROLLBARPOSINFO* pSBInfo = &m_spi[i];
        int ht = HitTestScrollBar(pSBInfo, ptClient);

        if (ht != HTNOWHERE)
        {
            TrackInit(ptClient, pSBInfo, (GetKeyState(VK_SHIFT) < 0) ? TRUE : FALSE);
            return;
        }
    }

    if (nHitTest == HTZOOM || nHitTest == HTREDUCE || nHitTest == HTCLOSE || nHitTest == HTHELP)
        return;

    CXTPSkinObject::OnNcLButtonDown(nHitTest, point);
}
Exemple #5
0
void duTreeCtrl::OnMouseMove(POINT pt)
{
	duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd);
	duRect rcTreeCtrl;
	Plugin_GetRect(this, &rcTreeCtrl);

	duRect rcItem;
	rcItem.SetRectEmpty();
	TreeCtrlItem *pItem = yHitTest(rcTreeCtrl, pt, rcItem);
	if (m_pHot != pItem)
	{
		m_pHot = pItem;
		Plugin_Redraw(this, TRUE);
		if(m_fShowTooltip)
		{
			pCtrlManager->DelToolTip();
			m_fShowTooltip = FALSE;
		}
	}
	
	if (pItem == NULL)
	{
		m_hitCode = tc_hit_empty;
		if(m_fShowTooltip)
		{
			pCtrlManager->DelToolTip();
			m_fShowTooltip = FALSE;
		}
	}
	else
	{
		POINT ptClient(pt);
		ptClient.x -= rcTreeCtrl.left;
		ptClient.y -= rcTreeCtrl.top;
		
		int nLeft = (pItem->nLevel - 1) * m_nIndentWidth;
		duRect rcIndent = CalcVCenterRect(rcItem, nLeft, m_nIndentWidth, m_nIndentHeight);
		if (ItemHasChildren(pItem) && (rcIndent.PtInRect(ptClient)))
			m_hitCode = tc_hit_indent;

		nLeft += (m_nIndentWidth + m_nIndentIconSpace);
		duRect rcIcon = CalcVCenterRect(rcItem, nLeft, m_nIconWidth, m_nIconHeight);
		if (rcIcon.PtInRect(ptClient))
			m_hitCode = tc_hit_icon;

		duRect rcText;
		nLeft += (m_nIconWidth + m_nIconTextSpace);
		rcText = rcItem;
		rcText.left = rcItem.left + nLeft;
		if (rcText.PtInRect(ptClient))
			m_hitCode = tc_hit_text;
	}
}
BOOL CXTPSkinObjectFrame::HandleMouseMove(CPoint point)
{
    CPoint ptClient(point);
    ScreenToFrame(&ptClient);

    CCaptionButton* pButton = HitTestButton(ptClient);

    if (m_pButtonHot != pButton)
    {
        if (m_pButtonHot && !pButton)
            CancelMouseLeaveTracking();

        m_pButtonHot = pButton;
        InvalidateButtons();

        if (m_pButtonHot)
        {
            SetTimer(XTP_TID_MOUSELEAVE, 50, &OnTimerInternal);
            return  TRUE;
        }
    }

    if (m_pSBTrack)
        return TRUE;

    BOOL bResult = FALSE;
    for (int i = 0; i < 2; i++)
    {
        XTP_SKINSCROLLBARPOSINFO* pSBInfo = &m_spi[i];
        int ht = HitTestScrollBar(pSBInfo, ptClient);

        if (ht != pSBInfo->ht && pSBInfo->fVisible)
        {
            if (pSBInfo->ht != HTNOWHERE && ht == HTNOWHERE && !bResult)
            {
                CancelMouseLeaveTracking();
            }

            pSBInfo->ht = ht;
            RedrawScrollBar(pSBInfo);
        }

        if (ht != HTNOWHERE)
        {
            SetTimer (XTP_TID_MOUSELEAVE, 50, &OnTimerInternal);
            bResult = TRUE;
        }
    }

    return bResult;
}
DWORD CTDCTaskListCtrl::HitTestTasksTask(const CPoint& ptScreen) const
{
	// see if we hit a task in the tree
	CPoint ptClient(ptScreen);
	m_lcTasks.ScreenToClient(&ptClient);
	
	int nItem = m_lcTasks.HitTest(ptClient);

	if (nItem != -1)
		return GetTaskID(nItem);

	// all else
	return 0;
}
UINT CExtResizableDialog::OnNcHitTest(CPoint point) 
{
	if( m_bShowGrip )
	{
		CPoint ptClient( point );
		ScreenToClient( &ptClient );
		CRect rcGrip;
		GetClientRect( &rcGrip );
		rcGrip.left = rcGrip.right - ::GetSystemMetrics( SM_CXVSCROLL );
		rcGrip.top = rcGrip.bottom - ::GetSystemMetrics( SM_CYHSCROLL );
		if( rcGrip.PtInRect(ptClient) )
			return HTBOTTOMRIGHT;
	} // if( m_bShowGrip )
	
	return CDialog::OnNcHitTest(point);
}
Exemple #9
0
UINT CChildView::OnNcHitTest(CPoint point) 
{
	CPoint ptClient(point);

	ScreenToClient(&ptClient);
	ptClient.y -= m_dz;
	if(m_rCltRect.PtInRect(ptClient))
	{
		return (HTCLIENT);
	}
	else 
	{
		return (CWnd::OnNcHitTest(point));
	}

//	return CWnd ::OnNcHitTest(point);
}
Exemple #10
0
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);
}
BOOL CTDCTaskListCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{
	if ((pWnd == &m_lcTasks) && !IsReadOnly() && !IsColumnShowing(TDCC_ICON))
	{
		UINT nHitFlags = 0;
		CPoint ptClient(::GetMessagePos());
		m_lcTasks.ScreenToClient(&ptClient);
	
		if ((m_lcTasks.HitTest(ptClient, &nHitFlags) != -1) && HasHitTestFlag(nHitFlags, LVHT_ONITEMICON))
		{
			::SetCursor(GraphicsMisc::HandCursor());
			return TRUE;
		}
	}
	
	// else
	return CTDCTaskCtrlBase::OnSetCursor(pWnd, nHitTest, message);
}
Exemple #12
0
TreeCtrlItem *duTreeCtrl::yHitTest(const duRect &rcTreeCtrl, const POINT pt, duRect &rcItem)
{
	POINT ptClient(pt);
	ptClient.x -= rcTreeCtrl.left;
	ptClient.y -= rcTreeCtrl.top;
	
	int nOffsetY = 0;
	TreeCtrlItem *pFirstVisible = GetFirstVisibleItem(nOffsetY);
	if (pFirstVisible == NULL || pFirstVisible == m_pRoot)
		return NULL;
	
	POINT ptView = GetViewPoint();
	duSize sizeView;
	GetViewSize(&sizeView);
	int nDrawHeight = -nOffsetY;
	TreeCtrlItem *pItem = pFirstVisible;
	while (pItem)
	{
		rcItem.SetRectEmpty();
		rcItem.left = -ptView.x;
		rcItem.right = rcItem.left + sizeView.cx;
		rcItem.top = nDrawHeight;
		rcItem.bottom = rcItem.top + m_nItemHeight;

		if (rcItem.PtInRect(ptClient))
			return pItem;

		if (nDrawHeight - nOffsetY > rcTreeCtrl.Height())
			break;

		nDrawHeight += m_nItemHeight;
		pItem = GetNextVisibleItem(pItem);
	}
	
	return NULL;
}
Exemple #13
0
LRESULT CToolBarPopup::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
    if ( WM_MOUSEFIRST <= message && message <= WM_MOUSELAST )
    {
        DWORD dwPos = ::GetMessagePos();
        CPoint ptScreen( LOWORD( dwPos ), HIWORD( dwPos ) );
        CWnd* pWnd = WindowFromPoint( ptScreen );
        if ( pWnd != 0 )
        {
            CPoint ptClient( ptScreen );
            pWnd->ScreenToClient( &ptClient );

            switch ( message )
            {
                case WM_MOUSEMOVE:
                {
                    // Check if hot item should be changed
                    bool bOverTbCtrl = ( pWnd == &m_tbCtrl );
                    if ( bOverTbCtrl )
                    {
                        int nHit = m_tbCtrl.HitTest( &ptClient );
                        m_tbCtrl.SetHotItem( nHit );

                        // Let tooltip control process mouse event
                        CToolTipCtrl* pTtCtrl = m_tbCtrl.GetToolTips();
                        if ( pTtCtrl != 0 )
                        {
                            MSG msg;
                            msg.hwnd    = m_tbCtrl.m_hWnd;
                            msg.message = WM_MOUSEMOVE;
                            msg.wParam  = wParam;
                            msg.lParam  = MAKELPARAM( ptClient.x, ptClient.y );
                            msg.pt      = ptScreen;
                            msg.time    = ::GetMessageTime();
                            pTtCtrl->RelayEvent( &msg );
                        }
                    }
                    else if ( m_bOverTbCtrl )
                    {
                        m_tbCtrl.SetHotItem( -1 );
                    }

                    m_bOverTbCtrl = bOverTbCtrl;
                    return 0L;
                }
                case WM_LBUTTONDOWN:
                    if ( pWnd != this )
                    {
                        // Dismiss menu if user has clicked outside the window
                        if ( pWnd != &m_tbCtrl )
                        {
                            SendMessage( WM_TB_ENDMODALLOOP );
                        }

                        // Forward this mouse event to the window that was clicked
                        LPARAM nPosition = MAKELPARAM( ptScreen.x, ptScreen.y );
                        WPARAM nHitTest  = pWnd->SendMessage( WM_NCHITTEST, 0, nPosition );
                        if ( nHitTest == HTCLIENT )
                        {
                            nPosition = MAKELPARAM( ptClient.x, ptClient.y );
                            pWnd->PostMessage( WM_LBUTTONDOWN, wParam, nPosition );
                        }
                        else
                        {
                            pWnd->PostMessage( WM_NCLBUTTONDOWN, nHitTest, nPosition );
                        }
                    }
                    return 0L;

                default:
                    break;
            }
        }
    }

    return CWnd::WindowProc( message, wParam, lParam );
}
Exemple #14
0
void CWindowListDlg::OnContextMenu(CWnd*, CPoint point) 
{
	CPoint ptClient(point);
	m_ctlWindowList.ScreenToClient(&ptClient);

	TCHITTESTINFO info;
	info.flags = TCHT_ONITEM;
	info.pt = ptClient;

	int nIndex = m_ctlWindowList.HitTest(&info);

	CWnd* pWnd = NULL;
	if (nIndex != -1)
	{
		CMenu menu;
		menu.LoadMenu(IDR_WNDLIST_RCLICK);
		CMenu *pMenu = menu.GetSubMenu(0);
		ASSERT(pMenu != NULL);

		WINDOWPLACEMENT placement = { sizeof(WINDOWPLACEMENT) };
		pWnd = GetWnd(nIndex);
		pWnd->GetWindowPlacement(&placement);

		if (placement.showCmd == SW_HIDE)
		{
			menu.EnableMenuItem(ID_WNDLIST_CLOSE, MF_BYCOMMAND | MF_GRAYED);
		}
		else if (placement.showCmd == SW_SHOWMAXIMIZED)
		{
			menu.EnableMenuItem(ID_WNDLIST_MAX,   MF_BYCOMMAND | MF_GRAYED);
		}
		else if (placement.showCmd == SW_SHOWMINIMIZED)
		{
			menu.EnableMenuItem(ID_WNDLIST_MIN,   MF_BYCOMMAND | MF_GRAYED);
		}
		else if (m_ctlWindowList.GetCurSel() == nIndex)
		{
			menu.EnableMenuItem(ID_WNDLIST_SHOW,  MF_BYCOMMAND | MF_GRAYED);
		}
		pWnd->GetWindowPlacement(&placement);

		int res = pMenu->TrackPopupMenu( (TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD),
					 point.x, point.y, this);

		switch(res)
		{
		case ID_WNDLIST_CLOSE:
			pWnd->PostMessage(WM_CLOSE);
			break;
		case ID_WNDLIST_MAX:
			placement.showCmd = SW_SHOWMAXIMIZED;
			pWnd->SetWindowPlacement(&placement);
			break;
		case ID_WNDLIST_MIN:
			placement.showCmd = SW_SHOWMINIMIZED;
			pWnd->SetWindowPlacement(&placement);
			break;
		case ID_WNDLIST_SHOW:
			pWnd->ShowWindow(SW_SHOWNORMAL);
			pWnd->BringWindowToTop();
			break;
		}
	}
}