From 1def58618cca824ea4b398b9fe5fbdf139b96a1c Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 4 Apr 2012 15:21:02 +0300 Subject: [PATCH] NowPlaying.dll: Changed OpenPlayer bang to always start foobar2000 activated (non-minimized) --- Plugins/PluginNowPlaying/PlayerCAD.cpp | 22 +++++++++++++++++++--- Plugins/PluginNowPlaying/PlayerCAD.h | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Plugins/PluginNowPlaying/PlayerCAD.cpp b/Plugins/PluginNowPlaying/PlayerCAD.cpp index 748cd470..4c279c63 100644 --- a/Plugins/PluginNowPlaying/PlayerCAD.cpp +++ b/Plugins/PluginNowPlaying/PlayerCAD.cpp @@ -34,7 +34,8 @@ extern HINSTANCE g_Instance; CPlayerCAD::CPlayerCAD() : CPlayer(), m_Window(), m_PlayerWindow(), - m_ExtendedAPI(false) + m_ExtendedAPI(false), + m_Open(false) { Initialize(); } @@ -380,6 +381,17 @@ LRESULT CALLBACK CPlayerCAD::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM { PostMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK); } + + if (player->m_Open) + { + if (wcscmp(windowSz, L"foobar2000") == 0) + { + // Activate foobar2000 in case it starts minimized + SendMessage(player->m_PlayerWindow, WM_USER, 0, IPC_SHOW_WINDOW); + } + + player->m_Open = false; + } } } } @@ -518,14 +530,18 @@ void CPlayerCAD::OpenPlayer(std::wstring& path) { if (!m_Initialized) { + HINSTANCE ret = NULL; + if (!path.empty()) { - ShellExecute(NULL, L"open", path.c_str(), NULL, NULL, SW_SHOW); + ret = ShellExecute(NULL, L"open", path.c_str(), NULL, NULL, SW_SHOW); } else if (!m_PlayerPath.empty()) { - ShellExecute(NULL, L"open", m_PlayerPath.c_str(), NULL, NULL, SW_SHOW); + ret = ShellExecute(NULL, L"open", m_PlayerPath.c_str(), NULL, NULL, SW_SHOW); } + + m_Open = (ret > (HINSTANCE)32); } else { diff --git a/Plugins/PluginNowPlaying/PlayerCAD.h b/Plugins/PluginNowPlaying/PlayerCAD.h index 3f8c1f88..671ad7bd 100644 --- a/Plugins/PluginNowPlaying/PlayerCAD.h +++ b/Plugins/PluginNowPlaying/PlayerCAD.h @@ -60,6 +60,7 @@ private: HWND m_PlayerWindow; std::wstring m_PlayerPath; bool m_ExtendedAPI; + bool m_Open; }; #endif