From a438e19f61836ef0ba658daca0f434c927c45a0c Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Fri, 30 Jun 2023 23:03:56 +0200 Subject: Windows: Support drag-n-drop of files in Expander for mounting. Fix drag-n-drop of keyfiles. To fix drag-n-drop of keyfiles, we remove the password drop target since it was blocking the standard drop of files and drop target doesn't work because of UIPI restrictions across privilege levels since Expander is started elevated --- src/ExpandVolume/WinMain.cpp | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp index 69f4c23b..c1ee3308 100644 --- a/src/ExpandVolume/WinMain.cpp +++ b/src/ExpandVolume/WinMain.cpp @@ -206,6 +206,7 @@ static void InitMainDialog (HWND hwndDlg) /* Call the common dialog init code */ InitDialog (hwndDlg); LocalizeDialog (hwndDlg, NULL); + DragAcceptFiles (hwndDlg, TRUE); SendMessage (GetDlgItem (hwndDlg, IDC_VOLUME), CB_LIMITTEXT, TC_MAX_PATH, 0); SetWindowTextW (hwndDlg, lpszTitle); @@ -516,17 +517,6 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SetWindowPos (hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } - - if (!bSecureDesktopOngoing) - { - PasswordEditDropTarget* pTarget = new PasswordEditDropTarget (); - if (pTarget->Register (hwndDlg)) - { - SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) pTarget); - } - else - delete pTarget; - } } return 0; @@ -819,19 +809,6 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA DragFinish (hdrop); } return 1; - - case WM_NCDESTROY: - { - /* unregister drap-n-drop support */ - PasswordEditDropTarget* pTarget = (PasswordEditDropTarget*) GetWindowLongPtr (hwndDlg, DWLP_USER); - if (pTarget) - { - SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) 0); - pTarget->Revoke (); - pTarget->Release(); - } - } - return 0; } return 0; @@ -1044,6 +1021,17 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa localcleanup (); return 0; + case WM_DROPFILES: + { + HDROP hdrop = (HDROP) wParam; + DragQueryFile (hdrop, 0, szFileName, ARRAYSIZE (szFileName)); + DragFinish (hdrop); + + AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory); + SetFocus (GetDlgItem (hwndDlg, IDOK)); + } + return 1; + case WM_COMMAND: if (lw == IDCANCEL || lw == IDC_EXIT) -- cgit v1.2.3