![]() |
|
#1
|
|||
|
|||
|
Hi all,
does anyone know how to make it that you can drag a folder onto a listview and have all the files displayed along with their associated icons? Is this hard to do ? Alternatively, is it possible to get the ShellListView to display the contents of one folder only i.e. a folder you drag over it. Any help/code fragments you can give is appreciated. thanks, Brendan. |
|
#2
|
|||
|
|||
|
Hi ...
To allow drag-drop in your application, use the following code: Code:
DragAcceptFiles(Self.Handle, True); Code:
protected
procedure WMDROPFILES(var Message: TMessage); message WM_DROPFILES;
...
procedure TTDSView.WMDROPFILES(var Message: TMessage);
var
FileName : array [0..254] of Char;
Hwnd : THandle;
FileCount : Byte;
begin
Hwnd := Message.WParam;
// Get the number of dropped files ...
FileCount := DragQueryFile(Hwnd, $FFFFFFFF, FileName, SizeOf(FileName));
try
if FileCount > 0
then begin
// Load the last file ...
DragQueryFile(Hwnd, FileCount - 1, FileName, SizeOf(FileName));
// Do something with FileName ...
end { if - FileCount > 0 };
finally
DragFinish(Hwnd);
end { finally - DragQueryFile };
end;
Code:
var
Ico : TIcon;
Extension : String;
SHFileInfo : TSHFILEINFO;
begin
Ico := TIcon.Create;
try
// Get the shortcut icon from the application ...
SHGetFileInfo(PChar(FileName),
0, SHFileInfo, SizeOf(SHFileInfo),
SHGFI_LARGEICON or SHGFI_ICON);
Ico.Handle := SHFileInfo.hIcon;
finally
Ico.Free;
end;
end;
MvG Peter Objective reality is a delirium caused by lack of alcohol in blood. 24 hous in a day, 24 beers in a case. Coincidence ??? There are 10 kinds of people: Those who understand binary and those who don't |
![]() |
| Thread Tools | |
| Display Modes | |
|
|