https://git.reactos.org/?p=reactos.git;a=commitdiff;h=83891d28434deea87da05…
commit 83891d28434deea87da05863c8ed937bfa7c6ef8
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Jul 19 05:02:49 2018 +0900
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Aug 9 14:08:05 2018 +0200
[CONSRV] Implement support for file/directory drag-and-drop (#692).
CORE-14833
---
win32ss/user/winsrv/consrv.cmake | 2 +-
win32ss/user/winsrv/consrv/frontends/gui/conwnd.c | 34 ++++++++++++++++++++++-
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/win32ss/user/winsrv/consrv.cmake b/win32ss/user/winsrv/consrv.cmake
index ea30acf25a..1307a0fb91 100644
--- a/win32ss/user/winsrv/consrv.cmake
+++ b/win32ss/user/winsrv/consrv.cmake
@@ -56,6 +56,6 @@ add_dependencies(consrv psdk)
add_pch(consrv consrv/consrv.h CONSRV_SOURCE)
#add_object_library(consrv ${CONSRV_SOURCE})
list(APPEND CONSRV_IMPORT_LIBS psapi)
-list(APPEND CONSRV_DELAY_IMPORT_LIBS ole32)
+list(APPEND CONSRV_DELAY_IMPORT_LIBS shell32 ole32)
list(APPEND CONSRV_TARGET_LINK_LIBS concfg uuid)
set_module_type(consrv module UNICODE)
diff --git a/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
b/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
index 6071a5dd9c..2c48f7841b 100644
--- a/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
+++ b/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
@@ -7,6 +7,7 @@
* Johannes Anderwald
* Jeffrey Morlan
* Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
+ * Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com)
*/
/* INCLUDES *******************************************************************/
@@ -14,6 +15,7 @@
#include <consrv.h>
#include <intrin.h>
#include <windowsx.h>
+#include <shellapi.h>
#define NDEBUG
#include <debug.h>
@@ -586,7 +588,7 @@ OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
PCONSRV_CONSOLE Console;
- if (NULL == GuiData)
+ if (GuiData == NULL)
{
DPRINT1("GuiConsoleNcCreate: No GUI data\n");
return FALSE;
@@ -639,6 +641,9 @@ OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
DPRINT("OnNcCreate - setting start event\n");
NtSetEvent(GuiData->hGuiInitEvent, NULL);
+ /* We accept dropped files */
+ DragAcceptFiles(GuiData->hWindow, TRUE);
+
return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
}
@@ -2100,6 +2105,29 @@ OnMove(PGUI_CONSOLE_DATA GuiData)
GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
}
+static VOID
+OnDropFiles(PCONSRV_CONSOLE Console, HDROP hDrop)
+{
+ LPWSTR pszPath;
+ WCHAR szPath[MAX_PATH + 2];
+
+ szPath[0] = L'"';
+
+ DragQueryFileW(hDrop, 0, &szPath[1], ARRAYSIZE(szPath) - 1);
+ DragFinish(hDrop);
+
+ if (wcschr(&szPath[1], L' ') != NULL)
+ {
+ StringCchCatW(szPath, ARRAYSIZE(szPath), L"\"");
+ pszPath = szPath;
+ }
+ else
+ {
+ pszPath = &szPath[1];
+ }
+
+ PasteText(Console, pszPath, wcslen(pszPath));
+}
/*
// HACK: This functionality is standard for general scrollbars. Don't add it by
hand.
@@ -2387,6 +2415,10 @@ ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
+ case WM_DROPFILES:
+ OnDropFiles(Console, (HDROP)wParam);
+ break;
+
case WM_SETFOCUS:
case WM_KILLFOCUS:
OnFocus(GuiData, (msg == WM_SETFOCUS));