コード例 #1
0
ファイル: FileView.cpp プロジェクト: yeehlin/PMP
void CFileView::OnContextMenu(CWnd* pWnd, CPoint point)
{
	CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView;
	ASSERT_VALID(pWndTree);

	if (pWnd != pWndTree)
	{
		CDockablePane::OnContextMenu(pWnd, point);
		return;
	}

	if (point != CPoint(-1, -1))
	{
		// Select clicked item:
		CPoint ptTree = point;
		pWndTree->ScreenToClient(&ptTree);

		UINT flags = 0;
		HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags);
		if (hTreeItem != NULL)
		{
			pWndTree->SelectItem(hTreeItem);
		}
	}

	pWndTree->SetFocus();
	theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE);
}
コード例 #2
0
ファイル: ClassView.cpp プロジェクト: ECNU-ZR/physwf-c-lab
void CClassView::OnContextMenu(CWnd* pWnd, CPoint point)
{
	CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView;
	ASSERT_VALID(pWndTree);

	if (pWnd != pWndTree)
	{
		CDockablePane::OnContextMenu(pWnd, point);
		return;
	}

	if (point != CPoint(-1, -1))
	{
		// 选择已单击的项:
		CPoint ptTree = point;
		pWndTree->ScreenToClient(&ptTree);

		UINT flags = 0;
		HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags);
		if (hTreeItem != NULL)
		{
			pWndTree->SelectItem(hTreeItem);
		}
	}

	pWndTree->SetFocus();
	CMenu menu;
	menu.LoadMenu(IDR_POPUP_SORT);

	CMenu* pSumMenu = menu.GetSubMenu(0);

	if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx)))
	{
		CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;

		if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE))
			return;

		((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu);
		UpdateDialogControls(this, FALSE);
	}
}
コード例 #3
0
BOOL TreeDlg::PreTranslateMessage(MSG *pMsg) {
  if(TranslateAccelerator(m_hWnd, m_accelTable, pMsg)) {
    return true;
  }

  switch(pMsg->message) {
  case WM_RBUTTONDOWN:
    { CTreeCtrl *ctrl = getTreeCtrl();
      CPoint     p    = pMsg->pt;
      ctrl->ScreenToClient(&p);
      HTREEITEM item = findTreeItemByPoint(ctrl, p);
      if(item != NULL) {
        const String derivation = getDerivation(ctrl, item, 160);
        showInformation(derivation);
        return TRUE;
      }
    }
    break;
  }
  return __super::PreTranslateMessage(pMsg);
}
コード例 #4
0
void CSiteView::OnContextMenu(CWnd* pWnd, CPoint point)
{
	CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView;
	ASSERT_VALID(pWndTree);

	if (pWnd != pWndTree)
	{
		CDockablePane::OnContextMenu(pWnd, point);
		return;
	}

	if (point != CPoint(-1, -1))
	{
		// Select clicked item:
		CPoint ptTree = point;
		pWndTree->ScreenToClient(&ptTree);

		UINT flags = 0;
		HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags);
		if (hTreeItem != NULL)
		{
			pWndTree->SelectItem(hTreeItem);
		}
	}
	HTREEITEM item = pWndTree->GetSelectedItem();
	TREE_T * item_data = (TREE_T*)pWndTree->GetItemData(item);
	pWndTree->SetFocus();

	if (item_data == NULL)
		theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_ROOT, point.x, point.y, this, TRUE);
	else if (item_data->tree_level == TREE_LEVEL_SITE)
		theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_SITES, point.x, point.y, this, TRUE);
	else if (item_data->tree_level == TREE_LEVEL_RECORDER)
		theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_RECORDER, point.x, point.y, this, TRUE);
	else if (item_data->tree_level==TREE_LEVEL_CAMERA)
		theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_CAMERA, point.x, point.y, this, TRUE);

}
コード例 #5
0
void CuListCtrlLoggedEvent::OnButtonUp(CPoint point)
{
	try
	{
		UINT flags = 0;
		UINT nFlags = 0;
		CPoint p = point;
		ClientToScreen (&p);

		if (!m_bDragging)
			return;
		m_bDragging = FALSE;

		ASSERT(m_pImageListDrag != NULL);
		m_pImageListDrag->DragLeave(GetParentFrame());
		m_pImageListDrag->EndDrag();
		delete m_pImageListDrag;
		m_pImageListDrag = NULL;

		if (m_iItemDrag == -1)
			return;

		//
		// Determine the pane under the mouse pointer:
		CRect rFrame, rLeftTree, rRightTree, rBottomList;
		m_pEventSettingFrame->GetWindowRect (rFrame);

		CvEventSettingLeft*   pLeftView  = m_pEventSettingFrame->GetLeftView();
		CvEventSettingRight*  pRightView = m_pEventSettingFrame->GetRightView();
		CvEventSettingBottom* pBottomView= m_pEventSettingFrame->GetBottomView();
		if (!(pLeftView && pRightView && pBottomView))
			return;
		CTreeCtrl* pTreeLeft  = pLeftView->GetTreeCtrl();
		CTreeCtrl* pTreeRight = pRightView->GetTreeCtrl();
		CListCtrl* pListBottom= pBottomView->GetListCtrl();
		if (!(pTreeLeft && pTreeRight && pListBottom))
			return;

		pTreeLeft->GetWindowRect  (rLeftTree);
		pTreeRight->GetWindowRect (rRightTree);
		pListBottom->GetWindowRect(rBottomList);
		
		CWnd* pWndTarget = NULL;
		CPoint cursorPos;
		GetCursorPos (&cursorPos);

		int nPane = 0;
		if (rFrame.PtInRect (cursorPos))
		{
			if (rLeftTree.PtInRect (cursorPos))
			{
				pWndTarget = pTreeLeft;
				nPane = 1;
			}
			else
			if (rRightTree.PtInRect (cursorPos))
			{
				pWndTarget = pTreeRight;
				nPane = 2;
			}
			else
			if (rBottomList.PtInRect (cursorPos))
			{
				pWndTarget = pListBottom;
				nPane = 3;
			}
		}

		if (nPane == 1 || nPane == 2)
		{
			CTreeCtrl* pTree = NULL;
			CListCtrl* pListCtrl = pListBottom; 

			if (nPane == 1)
				pTree = pTreeLeft;
			else
				pTree = pTreeRight;

			UINT flags, nAction = 0;
			HTREEITEM hTreeItemTarget = NULL;
			CaMessageNode* pNodeTarget = NULL;
			CPoint pt = point;
			pt.y += 8;
			ClientToScreen (&pt);

			pTree->ScreenToClient(&pt);
			hTreeItemTarget = pTree->HitTest (pt, &flags);
			if (hTreeItemTarget && (flags&TVHT_ONITEM))
			{
				pTree->SelectItem (hTreeItemTarget);
				pNodeTarget = (CaMessageNode*)pTree->GetItemData (hTreeItemTarget);

				nAction = GetCompatibleSourceTarget(pTree, pNodeTarget->GetNodeInformation());
				NewUserMessage (nPane, nAction, pTree, pNodeTarget, pListCtrl);
			}
		}
	}
	catch (...)
	{
		TRACE0 ("Internal error(1): CuListCtrlLoggedEvent::OnButtonUp \n");
	}
	::ReleaseCapture();
}
コード例 #6
0
void CuListCtrlLoggedEvent::OnMouseMove(UINT nFlags, CPoint point) 
{
	CPoint p = point;
	ClientToScreen (&p);
	CPoint pDragMove = p;

	if (!m_pEventSettingFrame)
		m_pEventSettingFrame = (CfEventSetting*)GetParentFrame();
	ASSERT (m_pEventSettingFrame);
	if (!m_pEventSettingFrame)
	{
		CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
		return;
	}
	m_pEventSettingFrame->ScreenToClient(&pDragMove);

	if (!m_bDragging)
	{
		CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
		return;
	}
	
	ASSERT(m_pImageListDrag != NULL);
	m_pImageListDrag->DragMove(pDragMove);  // move the image
	m_pImageListDrag->DragLeave(/*this*/GetParentFrame());

	//
	// Determine the pane under the mouse pointer:
	CRect rFrame, rLeftTree, rRightTree, rBottomList;
	m_pEventSettingFrame->GetWindowRect (rFrame);

	CvEventSettingLeft*   pLeftView  = m_pEventSettingFrame->GetLeftView();
	CvEventSettingRight*  pRightView = m_pEventSettingFrame->GetRightView();
	CvEventSettingBottom* pBottomView= m_pEventSettingFrame->GetBottomView();
	if (!(pLeftView && pRightView && pBottomView))
	{
		CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
		return;
	}
	CTreeCtrl* pTreeLeft  = pLeftView->GetTreeCtrl();
	CTreeCtrl* pTreeRight = pRightView->GetTreeCtrl();
	CListCtrl* pListBottom= pBottomView->GetListCtrl();
	if (!(pTreeLeft && pTreeRight && pListBottom))
	{
		CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
		return;
	}

	pTreeLeft->GetWindowRect  (rLeftTree);
	pTreeRight->GetWindowRect (rRightTree);
	pListBottom->GetWindowRect(rBottomList);
	
	CWnd* pWndTarget = NULL;
	CPoint cursorPos;
	GetCursorPos (&cursorPos);

	int nPane = 0;
	if (rFrame.PtInRect (cursorPos))
	{
		if (rLeftTree.PtInRect (cursorPos))
		{
			pWndTarget = pTreeLeft;
			nPane = 1;
		}
		else
		if (rRightTree.PtInRect (cursorPos))
		{
			pWndTarget = pTreeRight;
			nPane = 2;
		}
		else
		if (rBottomList.PtInRect (cursorPos))
		{
			pWndTarget = pListBottom;
			nPane = 3;
		}
	}

	if (nPane == 1 || nPane == 2)
	{
		CTreeCtrl* pTree = NULL;
		if (nPane == 1)
			pTree = pTreeLeft;
		else
			pTree = pTreeRight;

		UINT flags, nAction = 0;
		HTREEITEM hTreeItemTarget = NULL;
		CaMessageNode* pNodeTarget = NULL;
		CPoint pt = point;
		pt.y += 8;
		ClientToScreen (&pt);

		pTree->ScreenToClient(&pt);
		hTreeItemTarget = pTree->HitTest (pt, &flags);
		if (hTreeItemTarget && (flags&TVHT_ONITEM))
		{
			pTree->SelectItem (hTreeItemTarget);
			pNodeTarget = (CaMessageNode*)pTree->GetItemData (hTreeItemTarget);
			nAction = GetCompatibleSourceTarget(pTree,pNodeTarget->GetNodeInformation());
		}
		TRACE1 ("DD Action = %x\n", nAction);

		if (nAction != 0)
			::SetCursor (theApp.m_hCursorDropCategory);
		else
			::SetCursor (theApp.m_hCursorNoDropCategory);
	}
	else
	{
		::SetCursor (theApp.m_hCursorNoDropCategory);
	}
	m_pImageListDrag->DragEnter(GetParentFrame(), pDragMove);  // lock updates and show drag image

	CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
}