diff --git a/Application/Application.vcxproj.filters b/Application/Application.vcxproj.filters index 6bd57c8b..079efa20 100644 --- a/Application/Application.vcxproj.filters +++ b/Application/Application.vcxproj.filters @@ -19,11 +19,6 @@ Source Files - - - Source Files - - Header Files @@ -34,4 +29,9 @@ Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/Library/DialogAbout.cpp b/Library/DialogAbout.cpp index 4ce7ee32..0bcf55da 100644 --- a/Library/DialogAbout.cpp +++ b/Library/DialogAbout.cpp @@ -218,17 +218,16 @@ INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam) HICON hIcon = LoadIcon(Rainmeter->GetInstance(), MAKEINTRESOURCE(IDI_TRAY)); SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); - std::wstring tmpSz; HWND item = GetDlgItem(m_Window, IDC_ABOUT_TAB); TCITEM tci = {0}; tci.mask = TCIF_TEXT; - tci.pszText = GetString(ID_STR_LOG, tmpSz); + tci.pszText = GetString(ID_STR_LOG); TabCtrl_InsertItem(item, 0, &tci); - tci.pszText = GetString(ID_STR_MEASURES, tmpSz); + tci.pszText = GetString(ID_STR_MEASURES); TabCtrl_InsertItem(item, 1, &tci); - tci.pszText = GetString(ID_STR_PLUGINS, tmpSz); + tci.pszText = GetString(ID_STR_PLUGINS); TabCtrl_InsertItem(item, 2, &tci); - tci.pszText = GetString(ID_STR_VERSION, tmpSz); + tci.pszText = GetString(ID_STR_VERSION); TabCtrl_InsertItem(item, 3, &tci); HINSTANCE instance = Rainmeter->GetResourceInstance(); @@ -369,21 +368,20 @@ void CDialogAbout::CTabLog::Initialize() ListView_SetImageList(item, (WPARAM)hImageList, LVSIL_SMALL); - std::wstring tmpSz; LVCOLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; // left-aligned column lvc.iSubItem = 0; lvc.cx = 75; - lvc.pszText = GetString(ID_STR_TYPE, tmpSz); + lvc.pszText = GetString(ID_STR_TYPE); ListView_InsertColumn(item, 0, &lvc); lvc.iSubItem = 1; lvc.cx = 85; - lvc.pszText = GetString(ID_STR_TIME, tmpSz); + lvc.pszText = GetString(ID_STR_TIME); ListView_InsertColumn(item, 1, &lvc); lvc.iSubItem = 2; lvc.cx = 370; - lvc.pszText = GetString(ID_STR_MESSAGE, tmpSz); + lvc.pszText = GetString(ID_STR_MESSAGE); ListView_InsertColumn(item, 2, &lvc); // Add stored entires @@ -581,21 +579,20 @@ void CDialogAbout::CTabMeasures::Initialize() HWND item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTVIEW); ListView_SetExtendedListViewStyleEx(item, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER); - std::wstring tmpSz; LVCOLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; // left-aligned column lvc.iSubItem = 0; lvc.cx = 120; - lvc.pszText = GetString(ID_STR_NAME, tmpSz); + lvc.pszText = GetString(ID_STR_NAME); ListView_InsertColumn(item, 0, &lvc); lvc.iSubItem = 1; lvc.cx = 90; - lvc.pszText = GetString(ID_STR_RANGE, tmpSz); + lvc.pszText = GetString(ID_STR_RANGE); ListView_InsertColumn(item, 1, &lvc); lvc.iSubItem = 2; lvc.cx = 130; - lvc.pszText = GetString(ID_STR_VALUE, tmpSz); + lvc.pszText = GetString(ID_STR_VALUE); ListView_InsertColumn(item, 2, &lvc); // Add entries for each config @@ -863,21 +860,20 @@ void CDialogAbout::CTabPlugins::Initialize() // Add columns to the list view HWND item = GetDlgItem(m_Window, IDC_ABOUTPLUGINS_ITEMS_LISTVIEW); - std::wstring tmpSz; LVCOLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; // left-aligned column lvc.iSubItem = 0; lvc.cx = 140; - lvc.pszText = GetString(ID_STR_NAME, tmpSz); + lvc.pszText = GetString(ID_STR_NAME); ListView_InsertColumn(item, 0, &lvc); lvc.iSubItem = 1; lvc.cx = 80; - lvc.pszText = GetString(ID_STR_VERSION, tmpSz); + lvc.pszText = GetString(ID_STR_VERSION); ListView_InsertColumn(item, 1, &lvc); lvc.iSubItem = 2; lvc.cx = 310; - lvc.pszText = GetString(ID_STR_AUTHOR, tmpSz); + lvc.pszText = GetString(ID_STR_AUTHOR); ListView_InsertColumn(item, 2, &lvc); LVITEM vitem; diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index 0810e3ac..2da8e88a 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -202,15 +202,14 @@ INT_PTR CDialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam) HICON hIcon = LoadIcon(Rainmeter->GetInstance(), MAKEINTRESOURCE(IDI_TRAY)); SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); - std::wstring tmpSz; HWND item = GetDlgItem(m_Window, IDC_MANAGE_TAB); TCITEM tci = {0}; tci.mask = TCIF_TEXT; - tci.pszText = GetString(ID_STR_SKINS, tmpSz); + tci.pszText = GetString(ID_STR_SKINS); TabCtrl_InsertItem(item, 0, &tci); - tci.pszText = GetString(ID_STR_THEMES, tmpSz); + tci.pszText = GetString(ID_STR_THEMES); TabCtrl_InsertItem(item, 1, &tci); - tci.pszText = GetString(ID_STR_SETTINGS, tmpSz); + tci.pszText = GetString(ID_STR_SETTINGS); TabCtrl_InsertItem(item, 2, &tci); HINSTANCE instance = Rainmeter->GetResourceInstance(); @@ -344,8 +343,7 @@ void CDialogManage::CTabSkins::Initialize() { m_Initialized = true; - std::wstring tmpSz; - GetString(ID_STR_ACTIVESKINS, tmpSz); + std::wstring tmpSz = GetString(ID_STR_ACTIVESKINS); if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA) { // Arrow down @@ -379,7 +377,7 @@ void CDialogManage::CTabSkins::Initialize() ShowWindow(item, SW_HIDE); item = GetDlgItem(m_Window, IDC_MANAGESKINS_DISPLAYMONITOR_BUTTON); - GetString(ID_STR_DISPLAYMONITOR, tmpSz); + GetString(ID_STR_DISPLAYMONITOR); if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA) { // Arrow down @@ -400,17 +398,17 @@ void CDialogManage::CTabSkins::Initialize() ComboBox_AddString(item, L"90%"); item = GetDlgItem(m_Window, IDC_MANAGESKINS_ZPOSITION_COMBOBOX); - ComboBox_AddString(item, GetString(ID_STR_ONDESKTOP, tmpSz)); - ComboBox_AddString(item, GetString(ID_STR_BOTTOM, tmpSz)); - ComboBox_AddString(item, GetString(ID_STR_NORMAL, tmpSz)); - ComboBox_AddString(item, GetString(ID_STR_TOPMOST, tmpSz)); - ComboBox_AddString(item, GetString(ID_STR_STAYTOPMOST, tmpSz)); + ComboBox_AddString(item, GetString(ID_STR_ONDESKTOP)); + ComboBox_AddString(item, GetString(ID_STR_BOTTOM)); + ComboBox_AddString(item, GetString(ID_STR_NORMAL)); + ComboBox_AddString(item, GetString(ID_STR_TOPMOST)); + ComboBox_AddString(item, GetString(ID_STR_STAYTOPMOST)); item = GetDlgItem(m_Window, IDC_MANAGESKINS_ONHOVER_COMBOBOX); - ComboBox_AddString(item, GetString(ID_STR_DONOTHING, tmpSz)); - ComboBox_AddString(item, GetString(ID_STR_HIDE, tmpSz)); - ComboBox_AddString(item, GetString(ID_STR_FADEIN, tmpSz)); - ComboBox_AddString(item, GetString(ID_STR_FADEOUT, tmpSz)); + ComboBox_AddString(item, GetString(ID_STR_DONOTHING)); + ComboBox_AddString(item, GetString(ID_STR_HIDE)); + ComboBox_AddString(item, GetString(ID_STR_FADEIN)); + ComboBox_AddString(item, GetString(ID_STR_FADEOUT)); m_HandleCommands = true; } @@ -478,7 +476,7 @@ void CDialogManage::CTabSkins::SetControls() if (m_SkinWindow) { - SetWindowText(item, GetString(ID_STR_UNLOAD, buffer, 64)); + SetWindowText(item, GetString(ID_STR_UNLOAD)); item = GetDlgItem(m_Window, IDC_MANAGESKINS_REFRESH_BUTTON); EnableWindow(item, TRUE); @@ -546,15 +544,14 @@ void CDialogManage::CTabSkins::SetControls() } else { - SetWindowText(item, GetString(ID_STR_LOAD, buffer, 64)); + SetWindowText(item, GetString(ID_STR_LOAD)); } } void CDialogManage::CTabSkins::DisableControls(bool clear) { HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_LOAD_BUTTON); - WCHAR buffer[64]; - SetWindowText(item, GetString(ID_STR_LOAD, buffer, 64)); + SetWindowText(item, GetString(ID_STR_LOAD)); if (clear) { @@ -1198,7 +1195,6 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam) HMENU menu = LoadMenu(Rainmeter->GetResourceInstance(), MAKEINTRESOURCE(IDR_MANAGESKINS_MENU)); if (menu && TreeView_GetItem(nm->hwndFrom, &tvi)) { - std::wstring tmpSz; HMENU subMenu; MENUITEMINFO mii = {0}; mii.cbSize = sizeof(MENUITEMINFO); @@ -1212,7 +1208,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam) if (tvi.state & TVIS_EXPANDED) { - mii.dwTypeData = GetString(ID_STR_COLLAPSE, tmpSz); + mii.dwTypeData = GetString(ID_STR_COLLAPSE); SetMenuItemInfo(subMenu, ID_CONTEXT_MANAGESKINSMENU_EXPAND, MF_BYCOMMAND, &mii); } } @@ -1224,7 +1220,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam) if (m_SkinWindow) { - mii.dwTypeData = GetString(ID_STR_UNLOAD, tmpSz); + mii.dwTypeData = GetString(ID_STR_UNLOAD); SetMenuItemInfo(subMenu, ID_CONTEXT_MANAGESKINSMENU_LOAD, MF_BYCOMMAND, &mii); } else diff --git a/Library/Library.vcxproj.filters b/Library/Library.vcxproj.filters index beb57252..17159efc 100644 --- a/Library/Library.vcxproj.filters +++ b/Library/Library.vcxproj.filters @@ -358,11 +358,6 @@ Source Files - - - Source Files - - Header Files @@ -613,4 +608,9 @@ Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/Library/Litestep.cpp b/Library/Litestep.cpp index 879c9645..13f886c2 100644 --- a/Library/Litestep.cpp +++ b/Library/Litestep.cpp @@ -732,26 +732,11 @@ void LogError(CError& error) CDialogAbout::ShowAboutLog(); } -WCHAR* GetString(UINT id, WCHAR* buffer, int len) -{ - LoadString(Rainmeter->GetResourceInstance(), id, buffer, len); - return buffer; -} - -WCHAR* GetString(UINT id, std::wstring& buffer) +WCHAR* GetString(UINT id) { LPWSTR pData; int len = LoadString(Rainmeter->GetResourceInstance(), id, (LPWSTR)&pData, 0); - if (len) - { - buffer.assign(pData, len); - } - else - { - buffer.clear(); - } - - return (WCHAR*)buffer.c_str(); + return len ? pData : L""; } std::wstring GetFormattedString(UINT id, ...) @@ -759,10 +744,9 @@ std::wstring GetFormattedString(UINT id, ...) LPWSTR pBuffer = NULL; va_list args = NULL; va_start(args, id); - std::wstring tmpSz; FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER, - GetString(id, tmpSz), + GetString(id), 0, 0, (LPWSTR)&pBuffer, @@ -771,7 +755,7 @@ std::wstring GetFormattedString(UINT id, ...) va_end(args); - tmpSz = pBuffer; + std::wstring tmpSz = pBuffer; LocalFree(pBuffer); return tmpSz; } diff --git a/Library/Litestep.h b/Library/Litestep.h index 6443f10a..a9fae239 100644 --- a/Library/Litestep.h +++ b/Library/Litestep.h @@ -62,8 +62,7 @@ std::wstring ConvertToWide(LPCSTR str); std::string ConvertToUTF8(LPCWSTR str); std::wstring ConvertUTF8ToWide(LPCSTR str); -WCHAR* GetString(UINT id, WCHAR* buffer, int len = 64); -WCHAR* GetString(UINT id, std::wstring& buffer); +WCHAR* GetString(UINT id); std::wstring GetFormattedString(UINT id, ...); HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd); diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 5016eadf..b4115ba0 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1763,6 +1763,8 @@ CRainmeter::~CRainmeter() FinalizeLitestep(); + if (m_ResourceInstance) FreeLibrary(m_ResourceInstance); + CoUninitialize(); GdiplusShutdown(m_GDIplusToken); @@ -3905,8 +3907,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow) // Put Update notifications in the Tray menu if (m_NewVersion) { - std::wstring tmpSz; - InsertMenu(subMenu, 0, MF_BYPOSITION, ID_CONTEXT_NEW_VERSION, GetString(ID_STR_UPDATEAVAILABLE, tmpSz)); + InsertMenu(subMenu, 0, MF_BYPOSITION, ID_CONTEXT_NEW_VERSION, GetString(ID_STR_UPDATEAVAILABLE)); HiliteMenuItem(Rainmeter->GetTrayWindow()->GetWindow(), subMenu, 0, MF_BYPOSITION | MF_HILITE); InsertMenu(subMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); } @@ -4396,8 +4397,7 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation) } if (!bSuccess) { - std::wstring error; - GetString(ID_STR_SETTINGSNOTWRITABLE, error); + std::wstring error = GetString(ID_STR_SETTINGSNOTWRITABLE); if (!bDefaultIniLocation) { diff --git a/Library/resource.h b/Library/resource.h index 1b158446..651d9b6b 100644 --- a/Library/resource.h +++ b/Library/resource.h @@ -78,6 +78,50 @@ #define IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON 1057 #define IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON 1058 +#define ID_STR_ISRTL 2000 +#define ID_STR_UPDATEAVAILABLE 2001 +#define ID_STR_LOG 2002 +#define ID_STR_MEASURES 2003 +#define ID_STR_PLUGINS 2004 +#define ID_STR_VERSION 2005 +#define ID_STR_TYPE 2006 +#define ID_STR_TIME 2007 +#define ID_STR_MESSAGE 2008 +#define ID_STR_NAME 2009 +#define ID_STR_RANGE 2010 +#define ID_STR_VALUE 2011 +#define ID_STR_AUTHOR 2012 +#define ID_STR_PATHDETAILS 2013 +#define ID_STR_SKINS 2014 +#define ID_STR_THEMES 2015 +#define ID_STR_SETTINGS 2016 +#define ID_STR_ACTIVESKINS 2017 +#define ID_STR_DISPLAYMONITOR 2018 +#define ID_STR_STAYTOPMOST 2019 +#define ID_STR_TOPMOST 2020 +#define ID_STR_NORMAL 2021 +#define ID_STR_BOTTOM 2022 +#define ID_STR_ONDESKTOP 2023 +#define ID_STR_DONOTHING 2024 +#define ID_STR_HIDE 2025 +#define ID_STR_FADEIN 2026 +#define ID_STR_FADEOUT 2027 +#define ID_STR_LOAD 2028 +#define ID_STR_UNLOAD 2029 +#define ID_STR_COLLAPSE 2030 +#define ID_STR_SETTINGSNOTWRITABLE 2031 +#define ID_STR_SETTINGSMOVEFILE 2032 +#define ID_STR_SETTINGSREADONLY 2033 +#define ID_STR_THEMEALREADYEXISTS 2034 +#define ID_STR_THEMESAVEFAIL 2035 +#define ID_STR_THEMEDELETE 2036 +#define ID_STR_LOGFILECREATED 2037 +#define ID_STR_LOGFILECREATEFAIL 2038 +#define ID_STR_LOGFILEDELETE 2039 +#define ID_STR_NOAVAILABLESKINS 2040 +#define ID_STR_UNABLETOACTIVATESKIN 2041 +#define ID_STR_UNABLETOREFRESHSKIN 2042 + #define ID_CONTEXT_REFRESH 4001 #define ID_CONTEXT_QUIT 4002 #define ID_CONTEXT_DISABLEDRAG 4003 @@ -140,48 +184,3 @@ #define ID_THEME_LAST 43000 #define ID_MONITOR_FIRST 43001 #define ID_MONITOR_LAST 44000 - -#define ID_STR_ISRTL 0 -#define ID_STR_UPDATEAVAILABLE 10 -#define ID_STR_LOG 20 -#define ID_STR_MEASURES 21 -#define ID_STR_PLUGINS 22 -#define ID_STR_VERSION 23 -#define ID_STR_TYPE 24 -#define ID_STR_TIME 25 -#define ID_STR_MESSAGE 26 -#define ID_STR_NAME 27 -#define ID_STR_RANGE 28 -#define ID_STR_VALUE 29 -#define ID_STR_AUTHOR 30 -#define ID_STR_PATHDETAILS 31 -#define ID_STR_SKINS 32 -#define ID_STR_THEMES 33 -#define ID_STR_SETTINGS 34 -#define ID_STR_ACTIVESKINS 35 -#define ID_STR_DISPLAYMONITOR 36 -#define ID_STR_STAYTOPMOST 37 -#define ID_STR_TOPMOST 38 -#define ID_STR_NORMAL 39 -#define ID_STR_BOTTOM 40 -#define ID_STR_ONDESKTOP 41 -#define ID_STR_DONOTHING 42 -#define ID_STR_HIDE 43 -#define ID_STR_FADEIN 44 -#define ID_STR_FADEOUT 45 -#define ID_STR_LOAD 46 -#define ID_STR_UNLOAD 47 -#define ID_STR_COLLAPSE 48 -#define ID_STR_SETTINGSNOTWRITABLE 49 -#define ID_STR_SETTINGSMOVEFILE 50 -#define ID_STR_SETTINGSREADONLY 51 -#define ID_STR_THEMEALREADYEXISTS 52 -#define ID_STR_THEMESAVEFAIL 53 -#define ID_STR_THEMEDELETE 54 -#define ID_STR_LOGFILECREATED 55 -#define ID_STR_LOGFILECREATEFAIL 56 -#define ID_STR_LOGFILEDELETE 57 -#define ID_STR_NOAVAILABLESKINS 58 -#define ID_STR_UNABLETOACTIVATESKIN 59 -#define ID_STR_UNABLETOREFRESHSKIN 60 -