https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f90a1956a53017de1fb9e…
commit f90a1956a53017de1fb9e4ea72ddda9c708db8a0
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sun Aug 27 19:41:13 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Aug 27 19:41:13 2023 +0900
[CLIPBRD] Support CF_HDROP format (#5622)
This allows to see what files are being copied into clipboard.
CORE-19140
---
base/applications/clipbrd/clipbrd.c | 7 +++++++
base/applications/clipbrd/cliputils.c | 3 ++-
base/applications/clipbrd/winutils.c | 39 +++++++++++++++++++++++++++++++++++
base/applications/clipbrd/winutils.h | 1 +
4 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/base/applications/clipbrd/clipbrd.c b/base/applications/clipbrd/clipbrd.c
index 6aaeaca88ea..e26f9eb2298 100644
--- a/base/applications/clipbrd/clipbrd.c
+++ b/base/applications/clipbrd/clipbrd.c
@@ -358,6 +358,13 @@ static void OnPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
break;
}
+ case CF_HDROP:
+ {
+ GetClientRect(hWnd, &rc);
+ HDropFromClipboard(hdc, &rc);
+ break;
+ }
+
default:
{
GetClientRect(hWnd, &rc);
diff --git a/base/applications/clipbrd/cliputils.c
b/base/applications/clipbrd/cliputils.c
index daee8439a8f..0d5e06060f3 100644
--- a/base/applications/clipbrd/cliputils.c
+++ b/base/applications/clipbrd/cliputils.c
@@ -164,7 +164,8 @@ UINT GetAutomaticClipboardFormat(void)
CF_DSPBITMAP,
CF_DSPMETAFILEPICT,
CF_DSPENHMETAFILE,
- CF_PALETTE
+ CF_PALETTE,
+ CF_HDROP
};
return GetPriorityClipboardFormat(uFormatList, ARRAYSIZE(uFormatList));
diff --git a/base/applications/clipbrd/winutils.c b/base/applications/clipbrd/winutils.c
index eb1cf03c2dc..d97b4fb710e 100644
--- a/base/applications/clipbrd/winutils.c
+++ b/base/applications/clipbrd/winutils.c
@@ -331,6 +331,45 @@ void PlayEnhMetaFileFromClipboard(HDC hdc, const RECT *lpRect)
PlayEnhMetaFile(hdc, hEmf, lpRect);
}
+static LPWSTR AllocStrCat(LPWSTR psz, LPCWSTR cat)
+{
+ INT cch;
+ LPWSTR pszNew;
+
+ if (psz == NULL)
+ return _wcsdup(cat);
+
+ cch = lstrlenW(psz) + lstrlenW(cat) + 1;
+ pszNew = realloc(psz, cch * sizeof(WCHAR));
+ if (!pszNew)
+ return psz;
+
+ lstrcatW(pszNew, cat);
+ return pszNew;
+}
+
+void HDropFromClipboard(HDC hdc, const RECT *lpRect)
+{
+ LPWSTR pszAlloc = NULL;
+ WCHAR szFile[MAX_PATH + 2];
+ HDROP hDrop = (HDROP)GetClipboardData(CF_HDROP);
+ UINT iFile, cFiles = DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0);
+ RECT rc = *lpRect;
+
+ FillRect(hdc, &rc, (HBRUSH)(COLOR_WINDOW + 1));
+
+ for (iFile = 0; iFile < cFiles; ++iFile)
+ {
+ DragQueryFileW(hDrop, iFile, szFile, _countof(szFile));
+ lstrcatW(szFile, L"\r\n");
+ pszAlloc = AllocStrCat(pszAlloc, szFile);
+ }
+
+ DrawTextW(hdc, pszAlloc, -1, &rc,
+ DT_LEFT | DT_NOPREFIX | DT_EXTERNALLEADING | DT_WORD_ELLIPSIS);
+ free(pszAlloc);
+}
+
BOOL RealizeClipboardPalette(HDC hdc)
{
BOOL Success;
diff --git a/base/applications/clipbrd/winutils.h b/base/applications/clipbrd/winutils.h
index e29ec927bc3..fe80eb148e8 100644
--- a/base/applications/clipbrd/winutils.h
+++ b/base/applications/clipbrd/winutils.h
@@ -17,4 +17,5 @@ void BitBltFromClipboard(PAINTSTRUCT ps, SCROLLSTATE state, DWORD
dwRop);
void SetDIBitsToDeviceFromClipboard(UINT uFormat, PAINTSTRUCT ps, SCROLLSTATE state, UINT
fuColorUse);
void PlayMetaFileFromClipboard(HDC hdc, const RECT *lpRect);
void PlayEnhMetaFileFromClipboard(HDC hdc, const RECT *lpRect);
+void HDropFromClipboard(HDC hdc, const RECT *lpRect);
BOOL RealizeClipboardPalette(HDC hdc);