Freez après un drag-drop depuis mon application
Bonjour, J'utilise le code ci-dessous pour faire un drag-drop depuis mon application, pour copier des fichiers.
Mais lorsque je fais cela, mon application se bloque jusqu'à ce que l'opération de copie se termine, comme il s'agit de gros fichiers :aie:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
procedure TclMainWnd.clMainMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
const
Threshold = 5;
var
SelFileList: TStrings;
i: Integer;
DataObject: IDataObject;
Effect: Integer;
Dh : TDropHandle;
begin
with Sender as TImage do
begin
if (filesList.Count > 0) and (csLButtonDown in ControlState)
and ((Abs(X - FDragStartPos.x) >= Threshold)
or (Abs(Y - FDragStartPos.y) >= Threshold)) then
begin
Perform(WM_LBUTTONUP, 0, MakeLong(X, Y));
SelFileList := TStringList.Create;
try
SelFileList.Capacity := filesList.Count;
for i := 0 to filesList.Count - 1 do
SelFileList.Add(filesList[i]);
DataObject := GetFileListDataObject('', SelFileList);
finally
SelFileList.Free;
end;
Effect := DROPEFFECT_COPY;
Dh:=TDropHandle.Create(DataObject);
Dh.Execute;
end;
end; |
C'est un code que j'ai trouvé sur Internet. :mrgreen:
J'ai du mal avec les API. Je crois qu'il faut un thread pour cette unique opération.
Pourriez-vous m'éclairer.
Merci.