共用方式為


CImageList::BeginDrag

Call this function to begin dragging an image.

BOOL BeginDrag( 
   int nImage, 
   CPoint ptHotSpot  
);

Parameters

  • nImage
    Zero-based index of the image to drag.

  • ptHotSpot
    Coordinates of the starting drag position (typically, the cursor position). The coordinates are relative to the upper left corner of the image.

Return Value

Nonzero if successful; otherwise 0.

Remarks

This function creates a temporary image list that is used for dragging. The image combines the specified image and its mask with the current cursor. In response to subsequent WM_MOUSEMOVE messages, you can move the drag image by using the DragMove member function. To end the drag operation, you can use the EndDrag member function.

Example

void CImageListDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
   // Initialize the drag image (usually called from WM_LBUTTONDOWN).
   m_myImageList.BeginDrag(0, CPoint(0, 0));
   m_myImageList.DragEnter(this, point);

   CDialog::OnLButtonDown(nFlags, point);
}

Requirements

Header: afxcmn.h

See Also

Reference

CImageList Class

Hierarchy Chart

CImageList::Draw

CImageList::EndDrag

CImageList::DragMove