Skip to content

Commit

Permalink
Built-in IDropTarget.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigocfd committed Jul 31, 2024
1 parent d13362c commit 937649b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Binary file modified res/flac-lame-frontend.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion src/DlgMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::wstring>& 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();
Expand Down
33 changes: 17 additions & 16 deletions src/DlgMain_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -100,6 +102,20 @@ INT_PTR DlgMain::onInitDialog()
return TRUE;
}

void DlgMain::onDropTarget(const std::vector<std::wstring>& 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<MINMAXINFO*>(lp);
Expand All @@ -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<HDROP>(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<std::vector<std::wstring>> files = dlg.showOpenFiles({
Expand Down

0 comments on commit 937649b

Please sign in to comment.