[SHIMGVW] Support Drag & Drop

- Use DragAcceptFiles and WM_DROPFILES.
CORE-19358
This commit is contained in:
Katayama Hirofumi MZ 2023-12-10 16:55:34 +09:00
parent 0b1d6d6b20
commit 468a5492a9

View file

@ -729,6 +729,8 @@ ZoomWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static BOOL
Preview_OnCreate(HWND hwnd, LPCREATESTRUCT pCS)
{
DragAcceptFiles(hwnd, TRUE);
g_hDispWnd = CreateWindowExW(WS_EX_CLIENTEDGE, WC_STATIC, L"",
WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, hwnd, NULL, g_hInstance, NULL);
@ -980,6 +982,20 @@ Preview_OnDestroy(HWND hwnd)
PostQuitMessage(0);
}
static VOID
Preview_OnDropFiles(HWND hwnd, HDROP hDrop)
{
WCHAR szFile[MAX_PATH];
DragQueryFileW(hDrop, 0, szFile, _countof(szFile));
pFreeFileList(g_pCurrentFile);
g_pCurrentFile = pBuildFileList(szFile);
pLoadImageFromNode(g_pCurrentFile, hwnd);
DragFinish(hDrop);
}
LRESULT CALLBACK
PreviewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@ -1023,6 +1039,11 @@ PreviewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Preview_OnSize(hwnd, (UINT)wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
break;
}
case WM_DROPFILES:
{
Preview_OnDropFiles(hwnd, (HDROP)wParam);
break;
}
case WM_DESTROY:
{
Preview_OnDestroy(hwnd);