| 970 | } |
| 971 | |
| 972 | bool handleFileDrop (HANDLE hdrop) |
| 973 | { |
| 974 | typedef UINT (WINAPI *DragQueryFileWFunc)(HANDLE, UINT, LPWSTR, UINT); |
| 975 | typedef BOOL (WINAPI *DragQueryPointFunc)(HANDLE, LPPOINT); |
| 976 | typedef BOOL (WINAPI *DragFinishFunc)(HANDLE); |
| 977 | |
| 978 | if (fileDropCallback) |
| 979 | { |
| 980 | if (auto shell32 = choc::file::DynamicLibrary ("shell32.dll")) |
| 981 | { |
| 982 | auto dragQueryFileW = reinterpret_cast<DragQueryFileWFunc> (shell32.findFunction ("DragQueryFileW")); |
| 983 | auto dragQueryPoint = reinterpret_cast<DragQueryPointFunc> (shell32.findFunction ("DragQueryPoint")); |
| 984 | auto dragFinish = reinterpret_cast<DragFinishFunc> (shell32.findFunction ("DragFinish")); |
| 985 | |
| 986 | POINT pt; |
| 987 | dragQueryPoint (hdrop, &pt); |
| 988 | FileDropEvent e; |
| 989 | e.x = static_cast<float> (pt.x); |
| 990 | e.y = static_cast<float> (pt.y); |
| 991 | |
| 992 | auto numFiles = dragQueryFileW (hdrop, 0xffffffff, nullptr, 0); |
| 993 | |
| 994 | for (UINT i = 0; i < numFiles; ++i) |
| 995 | { |
| 996 | auto size = dragQueryFileW (hdrop, i, nullptr, 0); |
| 997 | std::wstring path; |
| 998 | path.resize (size + 2); |
| 999 | dragQueryFileW (hdrop, i, path.data(), size + 1); |
| 1000 | e.filePaths.push_back (createUTF8FromUTF16 (path)); |
| 1001 | } |
| 1002 | |
| 1003 | dragFinish (hdrop); |
| 1004 | return fileDropCallback (e); |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | return false; |
| 1009 | } |
| 1010 | |
| 1011 | static void enableNonClientDPIScaling (HWND h) |
| 1012 | { |
no test coverage detected