void CTreeCtrlEx::OnTvnBegindrag(NMHDR *pNMHDR, LRESULT *pResult) { TRACE("OnTvnBeginrdrag\n"); NM_TREEVIEW* pNMTreeView=(NM_TREEVIEW*)pNMHDR; *pResult=0; m_hitemDrag=pNMTreeView->itemNew.hItem; m_hitemDrop=NULL; // моё ограничение на драг&дроп if(GetItemData(m_hitemDrag)<1000) return; m_pDragImage=CreateDragImageEx(m_hitemDrag); if(!m_pDragImage) return; m_bLDragging = TRUE; m_pDragImage->BeginDrag(0, CPoint(-15,-15)); POINT pt=pNMTreeView->ptDrag; ClientToScreen(&pt); m_pDragImage->DragEnter(NULL, pt); SetCapture(); }
void CDragDropListCtrl::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; if (pNMListView) { m_nPrevDropIndex = -1; m_uPrevDropState = NULL; // Items being dragged - can be one or more. m_anDragIndexes.RemoveAll(); POSITION pos = GetFirstSelectedItemPosition(); while (pos) { m_anDragIndexes.Add(GetNextSelectedItem(pos)); } DWORD dwStyle = GetStyle(); if ((dwStyle & LVS_SINGLESEL) == LVS_SINGLESEL) { // List control is single select; we need it to be multi-select so // we can show both the drag item and potential drag target as selected. m_dwStyle = dwStyle; ModifyStyle(LVS_SINGLESEL, NULL); } if (m_anDragIndexes.GetSize() > 0) { // Create a drag image from the centre point of the item image. // Clean up any existing drag image first. delete m_pDragImage; CPoint ptDragItem; m_pDragImage = CreateDragImageEx(&ptDragItem); if (m_pDragImage) { m_pDragImage->BeginDrag(0, ptDragItem); m_pDragImage->DragEnter(CWnd::GetDesktopWindow(), pNMListView->ptAction); // Capture all mouse messages in case the user drags outside the control. SetCapture(); } } } *pResult = 0; }
void CConditionsView::OnBeginrdrag(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; *pResult = 0; CTreeCtrl &tree = GetTreeCtrl(); CPoint ptAction; GetCursorPos(&ptAction); ScreenToClient(&ptAction); m_bRDragging = TRUE; m_bRDragCanceled = FALSE; m_hitemDrag = pNMTreeView->itemNew.hItem; m_hitemDrop = NULL; m_pDragImage = CreateDragImageEx(m_hitemDrag); // get the image list for dragging m_pDragImage->BeginDrag(0, CPoint(10,-15)); tree.SelectDropTarget(NULL); // to prevent image corruption. m_pDragImage->DragEnter(NULL, ptAction); SetCapture(); // get the drag condition HTREEITEM hItem = m_hitemDrag; // if (hItem == tree.GetRootItem()) return; // get the condition (if any) while ( tree.GetParentItem( hItem ) != tree.GetRootItem() ) hItem = tree.GetParentItem( hItem ); CString condName = tree.GetItemText( hItem ); CLogic_editorDoc *pDoc = static_cast<CLogic_editorDoc *> (GetDocument()); pDoc->m_conditions.Lookup( condName, (void*&) m_pDragCondition); }
void CSiteGroupsTree::OnBeginDrag(NMHDR *header, LRESULT *result) { NMTREEVIEW *info = reinterpret_cast<NMTREEVIEW *>(header); ASSERT(m_isDragging == false); m_draggedItem = info->itemNew.hItem; if (m_draggedItem) { m_droppedItem = 0; ASSERT(m_dragImageList.get() == 0); m_dragImageList.reset(CreateDragImageEx(m_draggedItem, IsDroppableItem(m_draggedItem) ? m_colors->droppable.color : m_colors->nondroppable.color)); if (m_dragImageList.get()) { m_isDragging = true; m_dragImageList->BeginDrag(0, DragHotspot); CPoint pt(info->ptDrag); ClientToScreen(&pt); m_dragImageList->DragEnter(this, pt); SetCapture(); } } *result = 0; }