本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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;
}