当前位置: 首页>>代码示例>>C++>>正文


C++ CImageList::BeginDrag方法代码示例

本文整理汇总了C++中CImageList::BeginDrag方法的典型用法代码示例。如果您正苦于以下问题:C++ CImageList::BeginDrag方法的具体用法?C++ CImageList::BeginDrag怎么用?C++ CImageList::BeginDrag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CImageList的用法示例。


在下文中一共展示了CImageList::BeginDrag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnLvnBegindrag

void CSharedDirsTreeCtrl::OnLvnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) 
{
	LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)pNMHDR;
	*pResult = 0;

	CDirectoryItem* pToDrag = (CDirectoryItem*)lpnmtv->itemNew.lParam;
	if (pToDrag == NULL || pToDrag->m_eItemType != SDI_UNSHAREDDIRECTORY || FileSystemTreeIsShared(pToDrag->m_strFullPath))
		return;

	ASSERT( m_pDraggingItem == NULL );
	delete m_pDraggingItem;
	m_pDraggingItem = pToDrag->CloneContent(); // to be safe we store a copy, as items can be deleted when collapsing the tree etc

	CImageList* piml = NULL;
	POINT ptOffset;
	RECT rcItem;
	if ((piml = CreateDragImage(lpnmtv->itemNew.hItem)) == NULL)
		return;

	/* get the bounding rectangle of the item being dragged (rel to top-left of control) */
	if (GetItemRect(lpnmtv->itemNew.hItem, &rcItem, TRUE))
	{
		CPoint ptDragBegin;
		int nX, nY;
		/* get offset into image that the mouse is at */
		/* item rect doesn't include the image */
		ptDragBegin = lpnmtv->ptDrag;
		ImageList_GetIconSize(piml->GetSafeHandle(), &nX, &nY);
		ptOffset.x = (ptDragBegin.x - rcItem.left) + (nX - (rcItem.right - rcItem.left));
		ptOffset.y = (ptDragBegin.y - rcItem.top) + (nY - (rcItem.bottom - rcItem.top));
		/* convert the item rect to screen co-ords, for use later */
		MapWindowPoints(NULL, &rcItem);
	}
	else
	{
		GetWindowRect(&rcItem);
		ptOffset.x = ptOffset.y = 8;
	}

	if (piml->BeginDrag(0, ptOffset))
	{
		CPoint ptDragEnter = lpnmtv->ptDrag;
		ClientToScreen(&ptDragEnter);
		piml->DragEnter(NULL, ptDragEnter);
	}
	delete piml;

	/* set the focus here, so we get a WM_CANCELMODE if needed */
	SetFocus();

	/* redraw item being dragged, otherwise it remains (looking) selected */
	InvalidateRect(&rcItem, TRUE);
	UpdateWindow();

	/* Hide the mouse cursor, and direct mouse input to this window */
	SetCapture(); 
}
开发者ID:machado2,项目名称:emule,代码行数:57,代码来源:SharedDirsTreeCtrl.cpp

示例2: CPoint

	void		OnDragEnter( CPoint& pointp ){
		if( m_pDragImage ){
			delete m_pDragImage;
		}
	
		m_pDragImage	= m_List.CreateDragImage( m_nDragIndex, &pt );
		ASSERT(m_pDragImage);

		m_pDragImage->BeginDrag( 0, CPoint(8, 8) );
		m_pDragImage->DragEnter( GetDesktopWindow(), ((NM_LISTVIEW *)pnmhdr)->ptAction );

		m_bDragging		= TRUE;
		m_hDropItem		= NULL;
		m_nDropIndex	= -1;
		m_pDropWnd		= &m_List;

		SetCapture();
	}
开发者ID:H2-T23,项目名称:garage,代码行数:18,代码来源:DragAndDropList.cpp

示例3: CreateDragImage

CImageList* CLiveList::CreateDragImage(CListCtrl* pList, const CPoint& ptMouse)
{
	ASSERT_VALID( pList );

	CPoint ptOffset( 0, 0 );
	CBitmap bmDrag;
	bmDrag.Attach( CreateDragImage( pList, ptMouse, ptOffset) );
	BITMAP bmpInfo;
	bmDrag.GetBitmap( &bmpInfo );
	CImageList* pAll = new CImageList();
	pAll->Create( bmpInfo.bmWidth, bmpInfo.bmHeight, ILC_COLOR32|ILC_MASK, 1, 1 ) ||
	pAll->Create( bmpInfo.bmWidth, bmpInfo.bmHeight, ILC_COLOR24|ILC_MASK, 1, 1 ) ||
	pAll->Create( bmpInfo.bmWidth, bmpInfo.bmHeight, ILC_COLOR16|ILC_MASK, 1, 1 );
	pAll->Add( &bmDrag, DRAG_COLOR_KEY );
	bmDrag.DeleteObject();
	pAll->BeginDrag( 0, ptOffset );

	return pAll;
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:19,代码来源:LiveList.cpp

示例4: OnBegindragMylist

void hdCLibDlg::OnBegindragMylist(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	m_dragItem = pNMTreeView->itemNew.hItem;

	if(m_dragItem!=ModelParent)
	{
		CImageList* pDragImage;
		pDragImage = m_mylist.CreateDragImage( m_dragItem );
		m_mylist.SelectItem( m_dragItem );
		pDragImage->BeginDrag( 0, CPoint(0,-14) );
		pDragImage->DragEnter(this, pNMTreeView->ptDrag);
		SetCapture();
		m_bIsDragging = TRUE;
		delete pDragImage;
		bDragFromLibrary=FALSE;
		SetTimer ( 1, 75, NULL ) ;
	}

	*pResult = 0;
}
开发者ID:philm001,项目名称:Omni-FEM,代码行数:21,代码来源:hd_libdlg.cpp


注:本文中的CImageList::BeginDrag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。