[CONSRV] Implement support for file/directory drag-and-drop (#692). 692/head
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Wed, 18 Jul 2018 20:02:49 +0000 (05:02 +0900)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 9 Aug 2018 12:08:05 +0000 (14:08 +0200)
CORE-14833

win32ss/user/winsrv/consrv.cmake
win32ss/user/winsrv/consrv/frontends/gui/conwnd.c

index ea30acf..1307a0f 100644 (file)
@@ -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)
index 6071a5d..2c48f78 100644 (file)
@@ -7,6 +7,7 @@
  *                  Johannes Anderwald
  *                  Jeffrey Morlan
  *                  Hermes Belusca-Maito (hermes.belusca@sfr.fr)
+ *                  Katayama Hirofumi MZ (katayama.hirofumi.mz@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));