How to implement a mouse drag and drop file

Source: Internet
Author: User
Tags microsoft frontpage

One.

1: Get the file name and path you want to drag and drop.

2: Get the target file name and path.

3: In the drag event, the file is copied from the original directory into the destination directory.

4: Get the file icon into the timagelist.

5: Displays the file name and icon in a way.

Some difficulty here is the fourth step, how to get the icon, now just learned to tell you again (in the TListView display icon as an example):

Add in header file: #define No_win32_lean_and_mean

In. cpp, add:

SHFILEINFO FileInfo;
THandle ImageListHandle;
ImageListHandle = SHGetFileInfo("C:\\WINDOWS\\Start Menu\\Programs\\Microsoft FrontPage.lnk", 0, &FileInfo, sizeof(FileInfo),
             SHGFI_SYSICONINDEX ¦ SHGFI_LARGEICON);
SendMessage(lstvwVirtualList->Handle, LVM_SETIMAGELIST, LVSIL_SMALL,
         ImageListHandle);
TListItem * pItem;
SHGetFileInfo("C:\\WINDOWS\\Start Menu\\Programs\\Microsoft FrontPage.lnk", 0, &FileInfo, sizeof(FileInfo),SHGFI_ICON;SHGFI_LARGEICON);
pItem=lstvwVirtualList->Items->Add();
pItem->ImageIndex=FileInfo.iIcon;
SHGetFileInfo("C:\\WINDOWS\\Start Menu\\Programs\\DRVSPACE.EXE", 0, &FileInfo, sizeof(FileInfo),SHGFI_ICON;SHGFI_LARGEICON );
pItem=lstvwVirtualList->Items->Add();
pItem->ImageIndex=FileInfo.iIcon;

This allows you to obtain an icon for 2 files, if any, other files can be added.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.