-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDropFilesEdit.cpp
More file actions
67 lines (53 loc) · 1.31 KB
/
DropFilesEdit.cpp
File metadata and controls
67 lines (53 loc) · 1.31 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// DropFilesEdit.cpp : implementation file
//
#include "stdafx.h"
#include "DropFilesEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static bool NoFilter(CString &)
{
return true;
}
/////////////////////////////////////////////////////////////////////////////
// CDropFilesEdit
CDropFilesEdit::CDropFilesEdit(LPCSTR multidrop_separator, bool (*filter)(CString &))
: m_separator(multidrop_separator), m_filter(filter)
{
if (!m_filter) m_filter = NoFilter;
}
CDropFilesEdit::~CDropFilesEdit()
{
}
BEGIN_MESSAGE_MAP(CDropFilesEdit, CEdit)
//{{AFX_MSG_MAP(CDropFilesEdit)
ON_WM_DROPFILES()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDropFilesEdit message handlers
void CDropFilesEdit::OnDropFiles(HDROP hDropInfo)
{
// TODO: Add your message handler code here and/or call default
TCHAR buf[256];
int n = 1;
if (!m_separator.IsEmpty()) {
n = DragQueryFile(hDropInfo, -1, NULL, 0);
}
CString file, files;
int i;
for(i=0; i<n; i++) {
DragQueryFile(hDropInfo, i, buf, sizeof buf / sizeof (TCHAR));
file = buf;
if (m_filter(file)) {
if (!files.IsEmpty()) {
files += m_separator;
}
files += file;
}
}
DragFinish(hDropInfo);
if (!files.IsEmpty()) SetWindowText(files);
}