diff --git a/res/flac-lame-frontend.rc b/res/flac-lame-frontend.rc index a221e65..a4584d1 100644 Binary files a/res/flac-lame-frontend.rc and b/res/flac-lame-frontend.rc differ diff --git a/src/DlgMain.h b/src/DlgMain.h index 93e9b78..d59fea3 100644 --- a/src/DlgMain.h +++ b/src/DlgMain.h @@ -21,10 +21,10 @@ class DlgMain final : public lib::DialogMain { INT_PTR dlgProc(UINT uMsg, WPARAM wp, LPARAM lp) override; INT_PTR onInitDialog(); + void onDropTarget(const std::vector& files) override; INT_PTR onGetMinMaxInfo(LPARAM lp); INT_PTR onSize(WPARAM wp, LPARAM lp); INT_PTR onInitMenuPopup(WPARAM wp); - INT_PTR onDropFiles(WPARAM wp); INT_PTR onMnuOpenFiles(); INT_PTR onMnuRemSelected(); INT_PTR onMnuAbout(); diff --git a/src/DlgMain_events.cpp b/src/DlgMain_events.cpp index fb85127..e425197 100644 --- a/src/DlgMain_events.cpp +++ b/src/DlgMain_events.cpp @@ -3,6 +3,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE, _In_ LPWSTR, _In_ int cmdShow) { + lib::ComOle oleLib; DlgMain d; return lib::runMain(d, hInst, DLG_MAIN, cmdShow, ICO_RONBURGUNDY, ACC_MAIN); } @@ -17,7 +18,6 @@ INT_PTR DlgMain::dlgProc(UINT uMsg, WPARAM wp, LPARAM lp) case WM_GETMINMAXINFO: return onGetMinMaxInfo(lp); case WM_SIZE: return onSize(wp, lp); case WM_INITMENUPOPUP: return onInitMenuPopup(wp); - case WM_DROPFILES: return onDropFiles(wp); case WM_COMMAND: switch (LOWORD(wp)) { case MNU_OPENFILES: return onMnuOpenFiles(); @@ -55,6 +55,8 @@ INT_PTR DlgMain::dlgProc(UINT uMsg, WPARAM wp, LPARAM lp) INT_PTR DlgMain::onInitDialog() { + dlg.registerDragDrop(); + _layout.add(lib::Layout::Act::Resize, lib::Layout::Act::Resize, {LST_FILES}) .add(lib::Layout::Act::None, lib::Layout::Act::Repos, {LBL_DEST, FRA_CONV, RAD_MP3, RAD_CBR, CMB_CBR, RAD_VBR, CMB_VBR, @@ -100,6 +102,20 @@ INT_PTR DlgMain::onInitDialog() return TRUE; } +void DlgMain::onDropTarget(const std::vector& files) +{ + for (const auto& file : files) { + if (lib::path::isDir(file)) { // if a directory, add all files inside of it + for (const auto& subFile : lib::path::dirList(file + L"\\*.mp3")) _addFileToList(subFile); + for (const auto& subFile : lib::path::dirList(file + L"\\*.flac")) _addFileToList(subFile); + for (const auto& subFile : lib::path::dirList(file + L"\\*.wav")) _addFileToList(subFile); + } else { + _addFileToList(file); // add single file + } + } + _finishAddingFilesToList(); +} + INT_PTR DlgMain::onGetMinMaxInfo(LPARAM lp) { auto pMmi = reinterpret_cast(lp); @@ -124,21 +140,6 @@ INT_PTR DlgMain::onInitMenuPopup(WPARAM wp) return TRUE; } -INT_PTR DlgMain::onDropFiles(WPARAM wp) -{ - for (const auto& file : dlg.droppedFiles(reinterpret_cast(wp))) { - if (lib::path::isDir(file)) { // if a directory, add all files inside of it - for (const auto& subFile : lib::path::dirList(file + L"\\*.mp3")) _addFileToList(subFile); - for (const auto& subFile : lib::path::dirList(file + L"\\*.flac")) _addFileToList(subFile); - for (const auto& subFile : lib::path::dirList(file + L"\\*.wav")) _addFileToList(subFile); - } else { - _addFileToList(file); // add single file - } - } - _finishAddingFilesToList(); - return TRUE; -} - INT_PTR DlgMain::onMnuOpenFiles() { std::optional> files = dlg.showOpenFiles({