From c73736dc76e116ddd95e23f9d7cc0aecb182f7c8 Mon Sep 17 00:00:00 2001 From: Ronny Fretel Date: Mon, 25 Jul 2016 15:47:15 -0500 Subject: [PATCH 1/2] Systray implementation --- audio-router-gui/app_list.cpp | 140 +++++---- audio-router-gui/audio-router-gui.vcxproj | 12 +- .../audio-router-gui.vcxproj.filters | 6 + audio-router-gui/clsSysTray.cpp | 91 ++++++ audio-router-gui/clsSysTray.h | 27 ++ audio-router-gui/dialog_main.cpp | 4 +- audio-router-gui/main.cpp | 265 +++++++++--------- audio-router-gui/resource.h | Bin 3176 -> 3502 bytes audio-router-gui/window.cpp | 30 +- audio-router-gui/window.h | 12 +- audio-router/audio-router.vcxproj | 10 +- audio-router/patcher.h | 172 ++++++------ bootstrapper/bootstrapper.vcxproj | 10 +- do/do.vcxproj | 10 +- 14 files changed, 469 insertions(+), 320 deletions(-) create mode 100644 audio-router-gui/clsSysTray.cpp create mode 100644 audio-router-gui/clsSysTray.h diff --git a/audio-router-gui/app_list.cpp b/audio-router-gui/app_list.cpp index 1f920b3..fe03bd1 100644 --- a/audio-router-gui/app_list.cpp +++ b/audio-router-gui/app_list.cpp @@ -1,114 +1,100 @@ #include "app_list.h" -#include -#include +#include < Psapi.h > +#include < algorithm > -bool app_list::populate_list(bool x86, const filters_t& filters) -{ - DWORD processes[1024], needed; - if(!EnumProcesses(processes, sizeof(processes), &needed)) - return false; +bool app_list::populate_list(bool x86, const filters_t & filters) { + DWORD processes[1024], needed; + if ( ! EnumProcesses(processes, sizeof(processes), & needed)) + return false; - for(DWORD i = 0; i < (needed / sizeof(DWORD)); i++) - { - app_info info; - info.id = processes[i]; - if(this->get_app_info(info, filters, x86, true)) - this->apps.push_back(info); + for (DWORD i = 0; i < (needed / sizeof(DWORD)); i++) { + app_info info; + info.id = processes[i]; + if (this->get_app_info(info, filters, x86, true)) + this->apps.push_back(info); } - return true; + return true; } -bool app_list::populate_list() -{ - filters_t filters; - filters.push_back(L"mmdevapi.dll"); - return this->populate_list(filters); +bool app_list::populate_list() { + filters_t filters; + filters.push_back(L"mmdevapi.dll"); + return this->populate_list(filters); } -bool app_list::populate_list(const filters_t& filters) -{ - this->apps.clear(); +bool app_list::populate_list(const filters_t & filters) { + this->apps.clear(); - if(!this->populate_list(true, filters)) - return false; + if ( ! this-> populate_list(true, filters)) + return false; #ifdef _WIN64 - return this->populate_list(false, filters); + return this - > populate_list(false, filters); #else - return true; + return true; #endif } -bool app_list::get_app_info(app_info& info, const filters_t& filters, bool x86, bool query_name) -{ - HMODULE hmodules[1024]; - DWORD needed; +bool app_list::get_app_info(app_info & info, const filters_t & filters, bool x86, bool query_name) { + HMODULE hmodules[1024]; + DWORD needed; HANDLE hprocess = OpenProcess( - PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, - FALSE, info.id); - if(hprocess == NULL) - return false; + PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, + FALSE, info.id); + if (hprocess == NULL) + return false; #ifdef _WIN64 - BOOL px86; - if(!IsWow64Process(hprocess, &px86)) - { - CloseHandle(hprocess); - return false; + BOOL px86; + if ( ! IsWow64Process(hprocess, & px86)) { + CloseHandle(hprocess); + return false; } - info.x86 = px86; + info.x86 = px86; #else - info.x86 = true; + info.x86 = true; #endif - if(query_name && EnumProcessModulesEx( - hprocess, hmodules, sizeof(hmodules), - &needed, x86 ? LIST_MODULES_32BIT : LIST_MODULES_64BIT)) - { - WCHAR name[MAX_PATH] = {0}; - std::wstring exename; - if(GetModuleBaseName(hprocess, hmodules[0], name, sizeof(name) / sizeof(WCHAR))) - { - _wcslwr(name); - exename = name; + if (query_name && EnumProcessModulesEx( + hprocess, hmodules, sizeof(hmodules), & needed, x86?LIST_MODULES_32BIT:LIST_MODULES_64BIT)) { + WCHAR name[MAX_PATH] = {0}; + std::wstring exename; + if (GetModuleBaseName(hprocess, hmodules[0], name, sizeof(name)/sizeof(WCHAR))) { + _wcslwr(name); + exename = name; // skip filter - if(filters.empty()) - { - info.name = exename; - CloseHandle(hprocess); - return true; + if (filters.empty()) { + info.name = exename; + CloseHandle(hprocess); + return true; } - for(DWORD j = 0; j < (needed / sizeof(HMODULE)); j++) - { - WCHAR name[MAX_PATH] = {0}; - if(GetModuleBaseName(hprocess, hmodules[j], name, sizeof(name) / sizeof(WCHAR))) - { - _wcslwr(name); - for(filters_t::const_iterator it = filters.begin(); it != filters.end(); it++) - if(*it == name) - { - info.name = exename; - CloseHandle(hprocess); - return true; - }; + for (DWORD j = 0; j < (needed / sizeof(HMODULE)); j++) { + WCHAR name[MAX_PATH] = {0}; + if (GetModuleBaseName(hprocess, hmodules[j], name, sizeof(name)/sizeof(WCHAR))) { + _wcslwr(name); + for (filters_t::const_iterator it = filters.begin(); it != filters.end(); it++) + if ( * it == name) { + info.name = exename; + CloseHandle(hprocess); + return true; + }; } } } } - CloseHandle(hprocess); - return !query_name; + CloseHandle(hprocess); + return ! query_name; } -bool app_list::get_app_info(app_info& info, const filters_t& filters, bool query_name) -{ - if(get_app_info(info, filters, true, query_name)) - return true; +bool app_list::get_app_info(app_info & info, const filters_t & filters, bool query_name) { + if (get_app_info(info, filters, true, query_name)) + return true; #ifdef _WIN64 - return get_app_info(info, filters, false, query_name); + return get_app_info(info, filters, false, query_name); #else - return false; + return false; #endif } \ No newline at end of file diff --git a/audio-router-gui/audio-router-gui.vcxproj b/audio-router-gui/audio-router-gui.vcxproj index 1523f64..b738164 100644 --- a/audio-router-gui/audio-router-gui.vcxproj +++ b/audio-router-gui/audio-router-gui.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -26,26 +26,26 @@ Application true - v120 + v140 Unicode Application true - v120 + v140 Unicode Application false - v120 + v140 true Unicode Application false - v120 + v140 true Unicode @@ -159,6 +159,7 @@ + @@ -182,6 +183,7 @@ + diff --git a/audio-router-gui/audio-router-gui.vcxproj.filters b/audio-router-gui/audio-router-gui.vcxproj.filters index de1426e..7245f82 100644 --- a/audio-router-gui/audio-router-gui.vcxproj.filters +++ b/audio-router-gui/audio-router-gui.vcxproj.filters @@ -69,6 +69,9 @@ Header Files + + Header Files + @@ -127,6 +130,9 @@ Source Files + + Source Files + diff --git a/audio-router-gui/clsSysTray.cpp b/audio-router-gui/clsSysTray.cpp new file mode 100644 index 0000000..16b91f1 --- /dev/null +++ b/audio-router-gui/clsSysTray.cpp @@ -0,0 +1,91 @@ +#include "clsSysTray.h" +#include "resource.h" + + +clsSysTray::clsSysTray() +{ + bInTray = false; + NotifyIconData.cbSize = sizeof(NotifyIconData); + NotifyIconData.uID = uID = 2; + NotifyIconData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; + NotifyIconData.uCallbackMessage = WM_TRAYNOTIFY; + NotifyIconData.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME)); + NotifyIconData.szTip[0] = '\0'; + NotifyIconData.hWnd = NULL; + + +} + + +clsSysTray::~clsSysTray() +{ +} + +BOOL clsSysTray::SetIcon(HICON hNewIcon) +{ + NotifyIconData.hIcon = hNewIcon; + if (bInTray) + { + BOOL iRetVal; + iRetVal = Shell_NotifyIcon(NIM_MODIFY, &NotifyIconData); + if (iRetVal) + { + bInTray = true; + } + return iRetVal; + } + else + return (1); +} + +HICON clsSysTray::GetIcon() +{ + return NotifyIconData.hIcon; +} + +BOOL clsSysTray::SetTipText(char *lpstrNewTipText) +{ + //strncpy(NotifyIconData.szTip, lpstrNewTipText); + if (bInTray) + { + BOOL iRetVal; + iRetVal = Shell_NotifyIcon(NIM_MODIFY, &NotifyIconData); + if (iRetVal) + { + bInTray = true; + } + return iRetVal; + } + else + return (1); +} + +char *clsSysTray::GetTipText() +{ + return "test"; // NotifyIconData.szTip; +} + +BOOL clsSysTray::AddIcon() +{ + BOOL iRetVal; + NotifyIconData.hWnd = hWnd; + NotifyIconData.uID = uID; + iRetVal = Shell_NotifyIcon(NIM_ADD, &NotifyIconData); + if (iRetVal) + { + bInTray = true; + + } + return iRetVal; +} + +BOOL clsSysTray::RemoveIcon() +{ + BOOL iRetVal; + iRetVal = Shell_NotifyIcon(NIM_DELETE, &NotifyIconData); + if (iRetVal) + { + bInTray = false; + } + return iRetVal; +} diff --git a/audio-router-gui/clsSysTray.h b/audio-router-gui/clsSysTray.h new file mode 100644 index 0000000..8ea7ab2 --- /dev/null +++ b/audio-router-gui/clsSysTray.h @@ -0,0 +1,27 @@ +#pragma once +#pragma warning(disable: 4996) + +#include + +#define WM_TRAYNOTIFY 0XA44C +#include + +class clsSysTray +{ +public: + clsSysTray(); + ~clsSysTray(); + BOOL SetIcon(HICON hNewIcon); + HICON GetIcon(); + BOOL SetTipText(char *lpstrNewTipText); + char *GetTipText(); + BOOL AddIcon(); + BOOL RemoveIcon(); + HWND hWnd; + UINT uID; +protected: + NOTIFYICONDATA NotifyIconData; + bool bInTray; +}; + + diff --git a/audio-router-gui/dialog_main.cpp b/audio-router-gui/dialog_main.cpp index 17aa13b..d4496de 100644 --- a/audio-router-gui/dialog_main.cpp +++ b/audio-router-gui/dialog_main.cpp @@ -15,9 +15,7 @@ dialog_main::~dialog_main() void dialog_main::clear_dialog_arrays() { - for(auto it = this->dialog_arrays.begin(); - it != this->dialog_arrays.end(); - it++) + for (auto it = this->dialog_arrays.begin(); it != this->dialog_arrays.end(); it++) { delete *it; } diff --git a/audio-router-gui/main.cpp b/audio-router-gui/main.cpp index d27a44c..d8cfff8 100644 --- a/audio-router-gui/main.cpp +++ b/audio-router-gui/main.cpp @@ -11,137 +11,144 @@ CAppModule _Module; HANDLE audio_router_mutex; + int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - /*srand(time(NULL));*/ - - /*global_routing_params* params = new global_routing_params; - params->version = 0; - params->local.module_name_ptr = (uint64_t)new wchar_t[wcslen(L"full\\path\\to\\module.dll") + 1]; - wcscpy((wchar_t*)params->local.module_name_ptr, L"full\\path\\to\\module.dll"); - params->local.device_id_ptr = (uint64_t)new wchar_t[wcslen(L"device id") + 1]; - wcscpy((wchar_t*)params->local.device_id_ptr, L"device id"); - - global_routing_params* params2 = new global_routing_params; - params2->version = 0; - params2->local.module_name_ptr = (uint64_t)new wchar_t[wcslen(L"full\\path\\to\\module.dll") + 1]; - wcscpy((wchar_t*)params2->local.module_name_ptr, L"full\\path\\to\\module.dll"); - params2->local.device_id_ptr = (uint64_t)new wchar_t[wcslen(L"device id") + 1]; - wcscpy((wchar_t*)params2->local.device_id_ptr, L"device id"); - params->next_global_ptr = (uint64_t)params2; - - global_routing_params* params3 = new global_routing_params; - params3->version = 0; - params3->local.module_name_ptr = (uint64_t)new wchar_t[wcslen(L"full\\path\\to\\module.dll") + 1]; - wcscpy((wchar_t*)params3->local.module_name_ptr, L"full\\path\\to\\module.dll"); - params3->local.device_id_ptr = NULL; - params2->next_global_ptr = (uint64_t)params3; - params3->next_global_ptr = NULL; - - unsigned char* serialized = serialize(params); - free(params); - global_routing_params* serialized_params = rebase(serialized); - - MessageBox(NULL, (wchar_t*)serialized_params->local.module_name_ptr, NULL, 0); - MessageBox(NULL, (wchar_t*)((global_routing_params*)serialized_params->next_global_ptr)->local.device_id_ptr, NULL, 0); - - delete [] serialized_params;*/ - - if(GetModuleHandle(L"Audio Router.exe") == NULL) - { - MessageBox( - NULL, L"Wrong application name. Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } - - { - security_attributes sec(GENERIC_ALL, security_attributes::DEFAULT); - assert(sec.get() != NULL); - audio_router_mutex = CreateMutex(sec.get(), FALSE, L"Local\\audio-router-mutex"); - } - if(audio_router_mutex == NULL) - { - MessageBox( - NULL, L"Mutex creation failed. Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } - else if(GetLastError() == ERROR_ALREADY_EXISTS) - { - CloseHandle(audio_router_mutex); - MessageBox( - NULL, L"Another instance of Audio Router is already running. " \ - L"Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } - - HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); - if(hr != S_OK) - { - CloseHandle(audio_router_mutex); - MessageBox( - NULL, L"COM could not be initialized. Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } - - if(_Module.Init(NULL, hInstance) != S_OK) - { - CoUninitialize(); - CloseHandle(audio_router_mutex); - MessageBox( - NULL, L"ATL could not be initialized. Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } - - ULONG_PTR gdiplusToken; - Gdiplus::GdiplusStartupInput gdiplusStartupInput; - if(Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL) != Gdiplus::Ok) - { - _Module.Term(); - CoUninitialize(); - CloseHandle(audio_router_mutex); - MessageBox( - NULL, L"GDI+ could not be initialized. Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } - - MSG msg = {0}; - //std::unique_ptr bootstrap; - //try - //{ - // // TODO: decide if create a dummy bootstapper in case if the initialization fails - // bootstrap.reset(new bootstrapper); - //} - //catch(std::wstring err) - //{ - // err += L"Audio Router will close."; - // MessageBox(NULL, err.c_str(), NULL, MB_ICONERROR); - // goto cleanup; - //} - { - window win/*(bootstrap.get())*/; - RECT r = {CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT + WIN_WIDTH, CW_USEDEFAULT + WIN_HEIGHT}; - if(win.CreateEx(NULL, &r) == NULL) - { - MessageBox(NULL, L"Could not create window. Audio Router will close.", NULL, MB_ICONERROR); - goto cleanup; - } - win.ShowWindow(nCmdShow); - win.UpdateWindow(); - - while(GetMessage(&msg, NULL, 0, 0) > 0) - { - if(win.dlg_main && IsDialogMessage(*win.dlg_main, &msg)) - continue; - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } + /*srand(time(NULL));*/ + + /*global_routing_params* params = new global_routing_params; + params->version = 0; + params->local.module_name_ptr = (uint64_t)new wchar_t[wcslen(L"full\\path\\to\\module.dll") + 1]; + wcscpy((wchar_t*)params->local.module_name_ptr, L"full\\path\\to\\module.dll"); + params->local.device_id_ptr = (uint64_t)new wchar_t[wcslen(L"device id") + 1]; + wcscpy((wchar_t*)params->local.device_id_ptr, L"device id"); + + global_routing_params* params2 = new global_routing_params; + params2->version = 0; + params2->local.module_name_ptr = (uint64_t)new wchar_t[wcslen(L"full\\path\\to\\module.dll") + 1]; + wcscpy((wchar_t*)params2->local.module_name_ptr, L"full\\path\\to\\module.dll"); + params2->local.device_id_ptr = (uint64_t)new wchar_t[wcslen(L"device id") + 1]; + wcscpy((wchar_t*)params2->local.device_id_ptr, L"device id"); + params->next_global_ptr = (uint64_t)params2; + + global_routing_params* params3 = new global_routing_params; + params3->version = 0; + params3->local.module_name_ptr = (uint64_t)new wchar_t[wcslen(L"full\\path\\to\\module.dll") + 1]; + wcscpy((wchar_t*)params3->local.module_name_ptr, L"full\\path\\to\\module.dll"); + params3->local.device_id_ptr = NULL; + params2->next_global_ptr = (uint64_t)params3; + params3->next_global_ptr = NULL; + + unsigned char* serialized = serialize(params); + free(params); + global_routing_params* serialized_params = rebase(serialized); + + MessageBox(NULL, (wchar_t*)serialized_params->local.module_name_ptr, NULL, 0); + MessageBox(NULL, (wchar_t*)((global_routing_params*)serialized_params->next_global_ptr)->local.device_id_ptr, NULL, 0); + + delete [] serialized_params;*/ + + if (GetModuleHandle(L"Audio Router.exe") == NULL) + { + MessageBox( + NULL, L"Wrong application name. Audio Router will close.", NULL, MB_ICONERROR); + return 0; + } + + { + security_attributes sec(GENERIC_ALL, security_attributes::DEFAULT); + assert(sec.get() != NULL); + audio_router_mutex = CreateMutex(sec.get(), FALSE, L"Local\\audio-router-mutex"); + } + + if (audio_router_mutex == NULL) + { + MessageBox( + NULL, L"Mutex creation failed. Audio Router will close.", NULL, MB_ICONERROR); + return 0; + } + else if (GetLastError() == ERROR_ALREADY_EXISTS) + { + CloseHandle(audio_router_mutex); + MessageBox( + NULL, L"Another instance of Audio Router is already running. " \ + L"Audio Router will close.", NULL, MB_ICONERROR); + return 0; + } + + HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); + if (hr != S_OK) + { + CloseHandle(audio_router_mutex); + MessageBox(NULL, L"COM could not be initialized. Audio Router will close.", NULL, MB_ICONERROR); + return 0; + } + + if (_Module.Init(NULL, hInstance) != S_OK) + { + CoUninitialize(); + CloseHandle(audio_router_mutex); + MessageBox( + NULL, L"ATL could not be initialized. Audio Router will close.", NULL, MB_ICONERROR); + return 0; + } + + ULONG_PTR gdiplusToken; + Gdiplus::GdiplusStartupInput gdiplusStartupInput; + if (Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL) != Gdiplus::Ok) + { + _Module.Term(); + CoUninitialize(); + CloseHandle(audio_router_mutex); + MessageBox( + NULL, L"GDI+ could not be initialized. Audio Router will close.", NULL, MB_ICONERROR); + return 0; + } + + MSG msg = { 0 }; + //std::unique_ptr bootstrap; + //try + //{ + // // TODO: decide if create a dummy bootstapper in case if the initialization fails + // bootstrap.reset(new bootstrapper); + //} + //catch(std::wstring err) + //{ + // err += L"Audio Router will close."; + // MessageBox(NULL, err.c_str(), NULL, MB_ICONERROR); + // goto cleanup; + //} + + { + window win/*(bootstrap.get())*/; + RECT r = { CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT + WIN_WIDTH, CW_USEDEFAULT + WIN_HEIGHT }; + + + if (win.CreateEx(NULL, &r) == NULL) + { + MessageBox(NULL, L"Could not create window. Audio Router will close.", NULL, MB_ICONERROR); + goto cleanup; + } + + win.ShowWindow(nCmdShow); + win.UpdateWindow(); + + while (GetMessage(&msg, NULL, 0, 0) > 0) + { + + if (win.dlg_main && IsDialogMessage(*win.dlg_main, &msg)) + continue; + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } cleanup: - Gdiplus::GdiplusShutdown(gdiplusToken); - _Module.Term(); - CoUninitialize(); // this thread should be the last one to call uninitialize - CloseHandle(audio_router_mutex); + Gdiplus::GdiplusShutdown(gdiplusToken); + _Module.Term(); + CoUninitialize(); // this thread should be the last one to call uninitialize + CloseHandle(audio_router_mutex); + + return (int)msg.wParam; +} - return (int)msg.wParam; -} \ No newline at end of file diff --git a/audio-router-gui/resource.h b/audio-router-gui/resource.h index 252eace1445e0bce90161d6872ba55d844b68cd9..ac8c89a14efbae6523f588404a05910b62c99c4d 100644 GIT binary patch delta 228 zcmaDMu}*q}0GFgcLkNQ>g9}3>kaTA7XYd2E9f4wwlRq+v>MDTc;(`1iplBpRJdg|k z!g#o91qK*2oZQGJD~YMYl_3JCI%F~~l;3KVw*+N!{y4a9~Fnhd-QTnzd^sKDR`)ZquD{ebQTx!w)a^_%~5W-dlg_main_b) delete this->dlg_main; delete this->form_view; @@ -27,11 +28,16 @@ int window::OnCreate(LPCREATESTRUCT lpcs) this->m_hWndClient = this->dlg_main->Create(this->m_hWnd); this->dlg_main->ShowWindow(SW_SHOW); + bIsVisible = true; + STray.hWnd = this->m_hWnd; + STray.SetTipText("Audio Router"); + STray.AddIcon(); return 0; } LRESULT window::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + if(wParam == SC_MINIMIZE) { for(dialog_main::dialog_arrays_t::iterator it = this->dlg_main->dialog_arrays.begin(); @@ -44,7 +50,9 @@ LRESULT window::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan { (*jt)->set_display_name(false, true); } + } + } else if(wParam == SC_RESTORE) { @@ -65,6 +73,24 @@ LRESULT window::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan return 0; } +LRESULT window::OnTrayNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled) +{ + switch (LOWORD(lParam) ) + { + case WM_LBUTTONDBLCLK: + if(bIsVisible){ + this->ShowWindow(SW_HIDE); + bIsVisible = false; + } + else { + this->ShowWindow(SW_SHOW); + bIsVisible = true; + } + return 0; + break; + } +} + LRESULT window::OnFileRefreshlist(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if(!this->dlg_main_b) @@ -74,7 +100,6 @@ LRESULT window::OnFileRefreshlist(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWn return 0; } - LRESULT window::OnAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { this->MessageBoxW( @@ -86,7 +111,6 @@ LRESULT window::OnAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BO return 0; } - LRESULT window::OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { RECT rc; @@ -119,4 +143,4 @@ LRESULT window::OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWnd LRESULT window::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { return HTCLOSE; -} \ No newline at end of file +} diff --git a/audio-router-gui/window.h b/audio-router-gui/window.h index 70d6b77..c0effd1 100644 --- a/audio-router-gui/window.h +++ b/audio-router-gui/window.h @@ -6,6 +6,8 @@ #include "licensing.h" #include +#include "clsSysTray.h" + #define WIN_WIDTH 970//400 #define WIN_HEIGHT 670//360 #define GET(type, item) reinterpret_cast(this->GetDlgItem(item)) @@ -14,6 +16,10 @@ class window : public CFrameWindowImpl { private: bool dlg_main_b; + + clsSysTray STray; + BOOL bIsVisible; + public: dialog_main* dlg_main; formview* form_view; @@ -25,8 +31,9 @@ class window : public CFrameWindowImpl DECLARE_FRAME_WND_CLASS(L"Audio Router", IDR_MAINFRAME); - BEGIN_MSG_MAP(window) - MESSAGE_HANDLER(WM_SYSCOMMAND, OnSysCommand) + BEGIN_MSG_MAP(window) + MESSAGE_HANDLER(WM_SYSCOMMAND, OnSysCommand) + MESSAGE_HANDLER(WM_TRAYNOTIFY, OnTrayNotify); MSG_WM_CREATE(OnCreate) /*MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTest)*/ CHAIN_MSG_MAP(CFrameWindowImpl) @@ -42,4 +49,5 @@ class window : public CFrameWindowImpl LRESULT OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnTrayNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); }; \ No newline at end of file diff --git a/audio-router/audio-router.vcxproj b/audio-router/audio-router.vcxproj index 9089c8e..279f9e7 100644 --- a/audio-router/audio-router.vcxproj +++ b/audio-router/audio-router.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -26,26 +26,26 @@ DynamicLibrary true - v120 + v140 Unicode DynamicLibrary true - v120 + v140 Unicode DynamicLibrary false - v120 + v140 true Unicode DynamicLibrary false - v120 + v140 true Unicode diff --git a/audio-router/patcher.h b/audio-router/patcher.h index a1c017d..aa49fc3 100644 --- a/audio-router/patcher.h +++ b/audio-router/patcher.h @@ -11,61 +11,61 @@ template class patcher { public: - typedef T func_t; - typedef size_t address_t; + typedef T func_t; + typedef size_t address_t; #pragma pack(push, 1) - struct jmp_to - { - typedef typename std::conditional< - std::is_same::value, - std::integral_constant, - std::integral_constant>::type mov_ax_t; - typename mov_ax_t::value_type mov_ax = mov_ax_t::value; - address_t addr; - WORD jmp_ax = 0xe0ff; - }; + struct jmp_to + { + typedef typename std::conditional< + std::is_same::value, + std::integral_constant, + std::integral_constant>::type mov_ax_t; + typename mov_ax_t::value_type mov_ax = mov_ax_t::value; + address_t addr; + WORD jmp_ax = 0xe0ff; + }; #pragma pack(pop) private: - const func_t patched_func; - void* original_func; - jmp_to old_bytes; - DWORD old_protect; - CRITICAL_SECTION critical_section; + const func_t patched_func; + void* original_func; + jmp_to old_bytes; + DWORD old_protect; + CRITICAL_SECTION critical_section; public: - patcher(func_t patched_func) : patched_func(patched_func), original_func(NULL) - { - InitializeCriticalSectionAndSpinCount(&this->critical_section, 0x00000400); - } + patcher(func_t patched_func) : patched_func(patched_func), original_func(NULL) + { + InitializeCriticalSectionAndSpinCount(&this->critical_section, 0x00000400); + } - ~patcher() - { - this->destroy(); - } + ~patcher() + { + this->destroy(); + } - void destroy() - { - this->revert(); - DeleteCriticalSection(&this->critical_section); - } + void destroy() + { + this->revert(); + DeleteCriticalSection(&this->critical_section); + } - int is_patched() const - { - if(IsBadReadPtr(this->original_func, sizeof(jmp_to))) - return 2; + int is_patched() const + { + if (IsBadReadPtr(this->original_func, sizeof(jmp_to))) + return 2; - return (int)(memcmp(this->original_func, &this->old_bytes, sizeof(jmp_to)) != 0); - } + return (int)(memcmp(this->original_func, &this->old_bytes, sizeof(jmp_to)) != 0); + } - const void* get_function() const {return this->original_func;} + const void* get_function() const { return this->original_func; } - int patch(void* func_address) - { - if(!func_address) - return 1; + int patch(void* func_address) + { + if (!func_address) + return 1; - //// patchable function must be 16 byte aligned to ensure atomic patching - //if((address_t)func_address & 0xf) - // return 3; + //// patchable function must be 16 byte aligned to ensure atomic patching + //if((address_t)func_address & 0xf) + // return 3; //#ifdef _WIN64 // const size_t size = 16; @@ -74,46 +74,46 @@ class patcher //#endif // assert(size >= sizeof(jmp_to)); // - if(!VirtualProtect(func_address, sizeof(jmp_to), PAGE_EXECUTE_READWRITE, &this->old_protect)) - return 2; - - this->original_func = func_address; - memcpy(&this->old_bytes, this->original_func, sizeof(jmp_to)); - this->apply(); - - return 0; - } - - void lock() {EnterCriticalSection(&this->critical_section);} - void unlock() {LeaveCriticalSection(&this->critical_section);} - - void revert() - { - if(IsBadWritePtr(this->original_func, sizeof(jmp_to))) - return; - - //if(this->patched) - { - // bad write ptr might happen if the dll that is patched - // is unloaded before this dll is unloaded - /*if(IsBadWritePtr(this->original_func, sizeof(jmp_to))) - return;*/ - memcpy(this->original_func, &this->old_bytes, sizeof(jmp_to)); - //this->patched = false; - } - } - - void apply() - { - if(IsBadWritePtr(this->original_func, sizeof(jmp_to))) - return; - - //if(!this->patched) - { - jmp_to patch; - patch.addr = (address_t)this->patched_func; - memcpy(this->original_func, &patch, sizeof(jmp_to)); - //this->patched = true; - } - } + if (!VirtualProtect(func_address, sizeof(jmp_to), PAGE_EXECUTE_READWRITE, &this->old_protect)) + return 2; + + this->original_func = func_address; + memcpy(&this->old_bytes, this->original_func, sizeof(jmp_to)); + this->apply(); + + return 0; + } + + void lock() { EnterCriticalSection(&this->critical_section); } + void unlock() { LeaveCriticalSection(&this->critical_section); } + + void revert() + { + if (IsBadWritePtr(this->original_func, sizeof(jmp_to))) + return; + + //if(this->patched) + { + // bad write ptr might happen if the dll that is patched + // is unloaded before this dll is unloaded + /*if(IsBadWritePtr(this->original_func, sizeof(jmp_to))) + return;*/ + memcpy(this->original_func, &this->old_bytes, sizeof(jmp_to)); + //this->patched = false; + } + } + + void apply() + { + if (IsBadWritePtr(this->original_func, sizeof(jmp_to))) + return; + + //if(!this->patched) + { + jmp_to patch; + patch.addr = (address_t)this->patched_func; + memcpy(this->original_func, &patch, sizeof(jmp_to)); + //this->patched = true; + } + } }; \ No newline at end of file diff --git a/bootstrapper/bootstrapper.vcxproj b/bootstrapper/bootstrapper.vcxproj index eedcf5e..bbc4ac0 100644 --- a/bootstrapper/bootstrapper.vcxproj +++ b/bootstrapper/bootstrapper.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -32,26 +32,26 @@ DynamicLibrary true - v120 + v140 Unicode DynamicLibrary true - v120 + v140 Unicode DynamicLibrary false - v120 + v140 true Unicode DynamicLibrary false - v120 + v140 true Unicode diff --git a/do/do.vcxproj b/do/do.vcxproj index 2bece19..6efb070 100644 --- a/do/do.vcxproj +++ b/do/do.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -26,26 +26,26 @@ Application true - v120 + v140 Unicode Application true - v120 + v140 Unicode Application false - v120 + v140 true Unicode Application false - v120 + v140 true Unicode From 3cbee6c56a37ed04e2ac1155a94c2631b0788846 Mon Sep 17 00:00:00 2001 From: Ronny Fretel Date: Fri, 26 Aug 2016 12:46:28 -0500 Subject: [PATCH 2/2] minimiza y cierra a systray - se cierra desde el menu File --- .gitignore | 2 + .vscode/.gitignore | 1 + audio-router-gui/audio-router-gui.rc | Bin 11918 -> 12264 bytes audio-router-gui/clsSysTray.cpp | 2 - audio-router-gui/main.cpp | 34 ++--- audio-router-gui/resource.h | Bin 3502 -> 3524 bytes audio-router-gui/window.cpp | 212 +++++++++++++++------------ audio-router-gui/window.h | 53 +++---- 8 files changed, 165 insertions(+), 139 deletions(-) create mode 100644 .vscode/.gitignore diff --git a/.gitignore b/.gitignore index 4612351..9199674 100644 --- a/.gitignore +++ b/.gitignore @@ -188,3 +188,5 @@ GeneratedArtifacts/ _Pvt_Extensions/ ModelManifest.xml /do/err.txt +/audio-router.VC.VC.opendb +/audio-router.VC.db diff --git a/.vscode/.gitignore b/.vscode/.gitignore new file mode 100644 index 0000000..fd844a8 --- /dev/null +++ b/.vscode/.gitignore @@ -0,0 +1 @@ +/.browse.VC.db diff --git a/audio-router-gui/audio-router-gui.rc b/audio-router-gui/audio-router-gui.rc index 53b4014d8ab3bab3331dadb27af16b95c1651ed9..a1a4718efbd5502e0e09283bdd01a32bf9a114c4 100644 GIT binary patch delta 212 zcmeB+eG$K*LT<8^eAeVXagNCiiXxNCWRq|Xw z@dyS_hLFjElH!}!$-iO}^ki^h2x5q52w?CB;!uWw$@U7WjGU9R6{Hn?8C)6sfMQAv zybN3noD5DtzB^F6AC%8IIZ;mB9BLI%l@3r10)k9NG8f2(S`N`Y`JjyGH@RwBOn5k3In2(pcV?Vz9uROWOxsO diff --git a/audio-router-gui/clsSysTray.cpp b/audio-router-gui/clsSysTray.cpp index 16b91f1..883311d 100644 --- a/audio-router-gui/clsSysTray.cpp +++ b/audio-router-gui/clsSysTray.cpp @@ -12,8 +12,6 @@ clsSysTray::clsSysTray() NotifyIconData.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME)); NotifyIconData.szTip[0] = '\0'; NotifyIconData.hWnd = NULL; - - } diff --git a/audio-router-gui/main.cpp b/audio-router-gui/main.cpp index d8cfff8..ac9692d 100644 --- a/audio-router-gui/main.cpp +++ b/audio-router-gui/main.cpp @@ -61,20 +61,20 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi audio_router_mutex = CreateMutex(sec.get(), FALSE, L"Local\\audio-router-mutex"); } - if (audio_router_mutex == NULL) - { - MessageBox( - NULL, L"Mutex creation failed. Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } - else if (GetLastError() == ERROR_ALREADY_EXISTS) - { - CloseHandle(audio_router_mutex); - MessageBox( - NULL, L"Another instance of Audio Router is already running. " \ - L"Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } + //if (audio_router_mutex == NULL) + //{ + // MessageBox( + // NULL, L"Mutex creation failed. Audio Router will close.", NULL, MB_ICONERROR); + // return 0; + //} + //else if (GetLastError() == ERROR_ALREADY_EXISTS) + //{ + // CloseHandle(audio_router_mutex); + // MessageBox( + // NULL, L"Another instance of Audio Router is already running. " \ + // L"Audio Router will close.", NULL, MB_ICONERROR); + // return 0; + //} HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); if (hr != S_OK) @@ -122,8 +122,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi { window win/*(bootstrap.get())*/; RECT r = { CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT + WIN_WIDTH, CW_USEDEFAULT + WIN_HEIGHT }; - - + + if (win.CreateEx(NULL, &r) == NULL) { MessageBox(NULL, L"Could not create window. Audio Router will close.", NULL, MB_ICONERROR); @@ -135,7 +135,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi while (GetMessage(&msg, NULL, 0, 0) > 0) { - + if (win.dlg_main && IsDialogMessage(*win.dlg_main, &msg)) continue; TranslateMessage(&msg); diff --git a/audio-router-gui/resource.h b/audio-router-gui/resource.h index ac8c89a14efbae6523f588404a05910b62c99c4d..eac18204c47d72e81cbac34f9951bfefac1165a2 100644 GIT binary patch delta 141 zcmZ1{eMEYL8{1?zE|tkOOj48cxTGdKu(3^^0OSiWicMa?%r Zk4&PI4R}N*&*L$f%)}xFX8+;Y1OWP4Aiy-s?A8{6b64zA5S>|2;sc^SAE^np-;!H>b8A%ww`!G$3bNIC;~en7S(P|R`i zM<&t9c5FJ68`$I~&jHgMlb^APi7GIJGx##ZGXw+m1jBSqW@Hq1*MQ1|0>xb!f`I00 u1F<24CIiAoH=qtbB%9qZZQdNst;;yMfK_7h0v?aa65L`yT4J&o?>YdPS|+9d diff --git a/audio-router-gui/window.cpp b/audio-router-gui/window.cpp index cf40ed2..c491d3b 100644 --- a/audio-router-gui/window.cpp +++ b/audio-router-gui/window.cpp @@ -4,143 +4,165 @@ telemetry* telemetry_m = NULL; window::window(/*bootstrapper* bootstrap*/) : dlg_main_b(true)/*, license(NULL)*//*, bootstrap(bootstrap)*/ { - this->dlg_main = new dialog_main(*this); - this->form_view = new formview(*this); + this->dlg_main = new dialog_main(*this); + this->form_view = new formview(*this); } window::~window() { STray.RemoveIcon(); - if(this->dlg_main_b) - delete this->dlg_main; - delete this->form_view; + if (this->dlg_main_b) + delete this->dlg_main; + delete this->form_view; - delete telemetry_m; - telemetry_m = NULL; + delete telemetry_m; + telemetry_m = NULL; } int window::OnCreate(LPCREATESTRUCT lpcs) { - telemetry_m = new telemetry; + telemetry_m = new telemetry; - /*this->license = new dialog_licensing(*this);*/ + /*this->license = new dialog_licensing(*this);*/ - this->m_hWndClient = this->dlg_main->Create(this->m_hWnd); - this->dlg_main->ShowWindow(SW_SHOW); + this->m_hWndClient = this->dlg_main->Create(this->m_hWnd); + this->dlg_main->ShowWindow(SW_SHOW); bIsVisible = true; STray.hWnd = this->m_hWnd; STray.SetTipText("Audio Router"); STray.AddIcon(); - return 0; + return 0; } LRESULT window::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - if(wParam == SC_MINIMIZE) - { - for(dialog_main::dialog_arrays_t::iterator it = this->dlg_main->dialog_arrays.begin(); - it != this->dlg_main->dialog_arrays.end(); - it++) - { - for(dialog_array::dialog_controls_t::iterator jt = (*it)->dialog_controls.begin(); - jt != (*it)->dialog_controls.end(); - jt++) - { - (*jt)->set_display_name(false, true); - } - - } - - } - else if(wParam == SC_RESTORE) - { - for(dialog_main::dialog_arrays_t::iterator it = this->dlg_main->dialog_arrays.begin(); - it != this->dlg_main->dialog_arrays.end(); - it++) - { - for(dialog_array::dialog_controls_t::iterator jt = (*it)->dialog_controls.begin(); - jt != (*it)->dialog_controls.end(); - jt++) - { - (*jt)->set_display_name(false, false); - } - } - } - - bHandled = FALSE; - return 0; + if (wParam == SC_MINIMIZE) { + for (dialog_main::dialog_arrays_t::iterator it = this->dlg_main->dialog_arrays.begin(); + it != this->dlg_main->dialog_arrays.end(); + it++) + { + for (dialog_array::dialog_controls_t::iterator jt = (*it)->dialog_controls.begin(); + jt != (*it)->dialog_controls.end(); + jt++) + { + (*jt)->set_display_name(false, true); + } + + } + + this->ShowWindow(SW_HIDE); + bIsVisible = false; + return 0; + + } else if (wParam == SC_RESTORE) { + for (dialog_main::dialog_arrays_t::iterator it = this->dlg_main->dialog_arrays.begin(); + it != this->dlg_main->dialog_arrays.end(); + it++) + { + for (dialog_array::dialog_controls_t::iterator jt = (*it)->dialog_controls.begin(); + jt != (*it)->dialog_controls.end(); + jt++) + { + (*jt)->set_display_name(false, false); + } + } + } else if (wParam == SC_CLOSE) { + this->ShowWindow(SW_HIDE); + bIsVisible = false; + return 0; + } + + + bHandled = FALSE; + return 0; } LRESULT window::OnTrayNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled) { - switch (LOWORD(lParam) ) + switch (LOWORD(lParam)) { - case WM_LBUTTONDBLCLK: - if(bIsVisible){ - this->ShowWindow(SW_HIDE); - bIsVisible = false; - } - else { - this->ShowWindow(SW_SHOW); - bIsVisible = true; - } - return 0; - break; + case WM_LBUTTONDBLCLK: + if (bIsVisible) { + this->ShowWindow(SW_HIDE); + bIsVisible = false; + } else { + this->ShowWindow(SW_SHOW); + this->BringWindowToTop(); + bIsVisible = true; + } + break; + case WM_RBUTTONUP: + + /*POINT lpClickPoint; + + UINT uFlag = MF_BYPOSITION | MF_STRING; + GetCursorPos(&lpClickPoint); + + HMENU hPopMenu = CreatePopupMenu(); + InsertMenu(hPopMenu, 0xFFFFFFFF, MF_BYPOSITION | MF_STRING, ID_POPUP_EXIT, _T("Exit"); +*/ + break; } + return 0; } LRESULT window::OnFileRefreshlist(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { - if(!this->dlg_main_b) - { - this->form_view->refresh_list(); - } - return 0; + if (!this->dlg_main_b) + { + this->form_view->refresh_list(); + } + return 0; } LRESULT window::OnAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { - this->MessageBoxW( - L"Audio Router version 0.10.2.\n" \ - L"\nIf you come across any bugs(especially relating to routing or duplicating), " \ - L"or just have an idea for a new feature, " \ - L"please send a PM to the developer on reddit: reddit.com/user/audiorouterdev/", - L"About", MB_ICONINFORMATION); - return 0; + this->MessageBoxW( + L"Audio Router version 0.10.2.\n" \ + L"\nIf you come across any bugs(especially relating to routing or duplicating), " \ + L"or just have an idea for a new feature, " \ + L"please send a PM to the developer on reddit: reddit.com/user/audiorouterdev/", + L"About", MB_ICONINFORMATION); + return 0; } LRESULT window::OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { - RECT rc; - this->GetClientRect(&rc); - - if(this->dlg_main_b) - { - this->dlg_main->DestroyWindow(); - delete this->dlg_main; - - this->m_hWndClient = this->form_view->Create(*this); - //this->form_view->ShowWindow(SW_SHOW); - this->form_view->SetWindowPos(NULL, &rc, SWP_NOZORDER | SWP_SHOWWINDOW); - } - else - { - this->form_view->DestroyWindow(); - - this->dlg_main = new dialog_main(*this); - this->m_hWndClient = this->dlg_main->Create(*this); - //this->dlg_main->ShowWindow(SW_SHOW); - this->dlg_main->SetWindowPos(NULL, &rc, SWP_NOZORDER | SWP_SHOWWINDOW); - } - - this->dlg_main_b = !this->dlg_main_b; - - return 0; + RECT rc; + this->GetClientRect(&rc); + + if (this->dlg_main_b) + { + this->dlg_main->DestroyWindow(); + delete this->dlg_main; + + this->m_hWndClient = this->form_view->Create(*this); + //this->form_view->ShowWindow(SW_SHOW); + this->form_view->SetWindowPos(NULL, &rc, SWP_NOZORDER | SWP_SHOWWINDOW); + } else + { + this->form_view->DestroyWindow(); + + this->dlg_main = new dialog_main(*this); + this->m_hWndClient = this->dlg_main->Create(*this); + //this->dlg_main->ShowWindow(SW_SHOW); + this->dlg_main->SetWindowPos(NULL, &rc, SWP_NOZORDER | SWP_SHOWWINDOW); + } + + this->dlg_main_b = !this->dlg_main_b; + + return 0; } LRESULT window::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - return HTCLOSE; + return HTCLOSE; +} + +LRESULT window::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + PostQuitMessage(0); + return 0; } diff --git a/audio-router-gui/window.h b/audio-router-gui/window.h index c0effd1..0d066bc 100644 --- a/audio-router-gui/window.h +++ b/audio-router-gui/window.h @@ -15,39 +15,42 @@ class window : public CFrameWindowImpl { private: - bool dlg_main_b; + bool dlg_main_b; clsSysTray STray; BOOL bIsVisible; - + public: - dialog_main* dlg_main; - formview* form_view; - /*dialog_licensing* license;*/ - /*bootstrapper* bootstrap;*/ + dialog_main* dlg_main; + formview* form_view; + /*dialog_licensing* license;*/ + /*bootstrapper* bootstrap;*/ - explicit window(/*bootstrapper**/); - ~window(); + explicit window(/*bootstrapper**/); + ~window(); - DECLARE_FRAME_WND_CLASS(L"Audio Router", IDR_MAINFRAME); + DECLARE_FRAME_WND_CLASS(L"Audio Router", IDR_MAINFRAME); BEGIN_MSG_MAP(window) MESSAGE_HANDLER(WM_SYSCOMMAND, OnSysCommand) - MESSAGE_HANDLER(WM_TRAYNOTIFY, OnTrayNotify); - MSG_WM_CREATE(OnCreate) - /*MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTest)*/ - CHAIN_MSG_MAP(CFrameWindowImpl) - COMMAND_ID_HANDLER(ID_FILE_REFRESHLIST, OnFileRefreshlist) - COMMAND_ID_HANDLER(ID_ABOUT, OnAbout) - COMMAND_ID_HANDLER(ID_FILE_SWITCHVIEW, OnFileSwitchview) - /*MSG_WM_NCHITTEST(OnNcHitTest)*/ - END_MSG_MAP() - - int OnCreate(LPCREATESTRUCT); - LRESULT OnFileRefreshlist(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); - LRESULT OnAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); - LRESULT OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); - LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + MESSAGE_HANDLER(WM_TRAYNOTIFY, OnTrayNotify) + MSG_WM_CREATE(OnCreate) + /*MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTest)*/ + CHAIN_MSG_MAP(CFrameWindowImpl) + COMMAND_ID_HANDLER(ID_FILE_REFRESHLIST, OnFileRefreshlist) + COMMAND_ID_HANDLER(ID_ABOUT, OnAbout) + COMMAND_ID_HANDLER(ID_FILE_SWITCHVIEW, OnFileSwitchview) + COMMAND_ID_HANDLER(ID_FILE_EXIT, OnFileExit) + /*MSG_WM_NCHITTEST(OnNcHitTest)*/ + END_MSG_MAP() + + int OnCreate(LPCREATESTRUCT); + LRESULT OnFileRefreshlist(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnTrayNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + }; \ No newline at end of file