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.