-
Notifications
You must be signed in to change notification settings - Fork 225
/
UFileDropper.cpp
52 lines (49 loc) · 1.71 KB
/
UFileDropper.cpp
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "UFileDropper.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
TDragDropHelper::TDragDropHelper(const HWND h)
:wndHandle(h)
{
::DragAcceptFiles(wndHandle, true);
}
//---------------------------------------------------------------------------
TDragDropHelper::~TDragDropHelper()
{
::DragAcceptFiles(wndHandle, false);
}
//---------------------------------------------------------------------------
__fastcall TFileDropper::TFileDropper(HDROP aDropHandle)
:DropHandle(aDropHandle)
{
}
//---------------------------------------------------------------------------
__fastcall TFileDropper::~TFileDropper()
{
::DragFinish(DropHandle);
}
//---------------------------------------------------------------------------
String TFileDropper::GetFile(int Index)
{
const int FileNameLength = ::DragQueryFile(DropHandle, Index, 0, 0);
String res;
res.SetLength(FileNameLength);
::DragQueryFile(DropHandle, Index, res.c_str(), FileNameLength + 1);
return res;
}
//---------------------------------------------------------------------------
int TFileDropper::GetFileCount()
{
return ::DragQueryFile(DropHandle, 0xFFFFFFFF, 0, 0);
}
//---------------------------------------------------------------------------
TPoint TFileDropper::GetPoint()
{
TPoint res(0,0);
DragQueryPoint(DropHandle, &res);
return res;
}
//---------------------------------------------------------------------------