From e22db0b887b37e765904631902cc6e681fe40955 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 23 Sep 2011 16:28:38 +0000 Subject: [PATCH] Added localization support. --- Application/Application.rc | 2 +- Library/DialogAbout.cpp | 79 +++++----- Library/DialogManage.cpp | 112 ++++++++------ Library/Library.rc | 306 +------------------------------------ Library/Litestep.cpp | 46 +++++- Library/Litestep.h | 6 +- Library/Rainmeter.cpp | 71 ++++----- Library/Rainmeter.h | 2 + Library/resource.h | 45 ++++++ Rainmeter.sln | 11 ++ 10 files changed, 242 insertions(+), 438 deletions(-) diff --git a/Application/Application.rc b/Application/Application.rc index 54ff680c..7c992dcd 100644 --- a/Application/Application.rc +++ b/Application/Application.rc @@ -48,7 +48,7 @@ BEGIN VALUE "FileDescription", "Rainmeter" VALUE "FileVersion", STRFILEVER VALUE "InternalName", "Rainmeter" - VALUE "LegalCopyright", "Copyright (C) 2010 - Rainy" + VALUE "LegalCopyright", "Copyright (C) 2011 - All authors" VALUE "OriginalFilename", "Rainmeter.exe" VALUE "ProductName", "Rainmeter" #ifdef _WIN64 diff --git a/Library/DialogAbout.cpp b/Library/DialogAbout.cpp index fa5ff4ce..4ce7ee32 100644 --- a/Library/DialogAbout.cpp +++ b/Library/DialogAbout.cpp @@ -70,7 +70,7 @@ void CDialogAbout::Open(int tab) { if (!c_Dialog) { - HINSTANCE instance = Rainmeter->GetInstance(); + HINSTANCE instance = Rainmeter->GetResourceInstance(); HWND owner = Rainmeter->GetTrayWindow()->GetWindow(); if (!CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUT_DIALOG), owner, DlgProc)) return; } @@ -218,19 +218,20 @@ 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 = L"Log"; + tci.pszText = GetString(ID_STR_LOG, tmpSz); TabCtrl_InsertItem(item, 0, &tci); - tci.pszText = L"Measures"; + tci.pszText = GetString(ID_STR_MEASURES, tmpSz); TabCtrl_InsertItem(item, 1, &tci); - tci.pszText = L"Plugins"; + tci.pszText = GetString(ID_STR_PLUGINS, tmpSz); TabCtrl_InsertItem(item, 2, &tci); - tci.pszText = L"Version"; + tci.pszText = GetString(ID_STR_VERSION, tmpSz); TabCtrl_InsertItem(item, 3, &tci); - HINSTANCE instance = Rainmeter->GetInstance(); + HINSTANCE instance = Rainmeter->GetResourceInstance(); m_TabLog = new CTabLog(CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUTLOG_DIALOG), m_Window, CTabLog::DlgProc)); m_TabMeasures = new CTabMeasures(CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUTMEASURES_DIALOG), m_Window, CTabMeasures::DlgProc)); m_TabPlugins = new CTabPlugins(CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUTPLUGINS_DIALOG), m_Window, CTabPlugins::DlgProc)); @@ -368,20 +369,21 @@ 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.pszText = L"Type"; lvc.cx = 75; + lvc.pszText = GetString(ID_STR_TYPE, tmpSz); ListView_InsertColumn(item, 0, &lvc); lvc.iSubItem = 1; lvc.cx = 85; - lvc.pszText = L"Time"; + lvc.pszText = GetString(ID_STR_TIME, tmpSz); ListView_InsertColumn(item, 1, &lvc); lvc.iSubItem = 2; lvc.cx = 370; - lvc.pszText = L"Message"; + lvc.pszText = GetString(ID_STR_MESSAGE, tmpSz); ListView_InsertColumn(item, 2, &lvc); // Add stored entires @@ -447,39 +449,43 @@ void CDialogAbout::CTabLog::Resize(int w, int h) */ void CDialogAbout::CTabLog::AddItem(int level, LPCWSTR time, LPCWSTR message) { + WCHAR buffer[32]; LVITEM vitem; vitem.mask = LVIF_IMAGE | LVIF_TEXT; vitem.iItem = 0; vitem.iSubItem = 0; + vitem.pszText = buffer; + HWND item; switch (level) { case LOG_ERROR: if (!m_Error) return; - vitem.pszText = L"Error"; + item = GetDlgItem(m_Window, IDC_ABOUTLOG_ERROR_CHECKBOX); vitem.iImage = 0; break; case LOG_WARNING: if (!m_Error) return; - vitem.pszText = L"Warning"; + item = GetDlgItem(m_Window, IDC_ABOUTLOG_WARNING_CHECKBOX); vitem.iImage = 1; break; case LOG_NOTICE: if (!m_Notice) return; - vitem.pszText = L"Notice"; + item = GetDlgItem(m_Window, IDC_ABOUTLOG_NOTICE_CHECKBOX); vitem.iImage = 2; break; case LOG_DEBUG: if (!m_Debug) return; - vitem.pszText = L"Debug"; + item = GetDlgItem(m_Window, IDC_ABOUTLOG_DEBUG_CHECKBOX); vitem.iImage = -1; break; } - - HWND item = GetDlgItem(m_Window, IDC_ABOUTLOG_ITEMS_LISTVIEW); + + GetWindowText(item, buffer, 32); + item = GetDlgItem(m_Window, IDC_ABOUTLOG_ITEMS_LISTVIEW); ListView_InsertItem(item, &vitem); ListView_SetItemText(item, vitem.iItem, 1, (WCHAR*)time); ListView_SetItemText(item, vitem.iItem, 2, (WCHAR*)message); @@ -575,20 +581,21 @@ 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.iSubItem = 0; - lvc.pszText = L"Name"; - lvc.cx = 120; lvc.fmt = LVCFMT_LEFT; // left-aligned column + lvc.iSubItem = 0; + lvc.cx = 120; + lvc.pszText = GetString(ID_STR_NAME, tmpSz); ListView_InsertColumn(item, 0, &lvc); lvc.iSubItem = 1; lvc.cx = 90; - lvc.pszText = L"Range"; + lvc.pszText = GetString(ID_STR_RANGE, tmpSz); ListView_InsertColumn(item, 1, &lvc); lvc.iSubItem = 2; lvc.cx = 130; - lvc.pszText = L"Value"; + lvc.pszText = GetString(ID_STR_VALUE, tmpSz); ListView_InsertColumn(item, 2, &lvc); // Add entries for each config @@ -856,20 +863,21 @@ 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.iSubItem = 0; - lvc.pszText = L"Name"; - lvc.cx = 140; lvc.fmt = LVCFMT_LEFT; // left-aligned column + lvc.iSubItem = 0; + lvc.cx = 140; + lvc.pszText = GetString(ID_STR_NAME, tmpSz); ListView_InsertColumn(item, 0, &lvc); lvc.iSubItem = 1; lvc.cx = 80; - lvc.pszText = L"Version"; + lvc.pszText = GetString(ID_STR_VERSION, tmpSz); ListView_InsertColumn(item, 1, &lvc); lvc.iSubItem = 2; lvc.cx = 310; - lvc.pszText = L"Author"; + lvc.pszText = GetString(ID_STR_AUTHOR, tmpSz); ListView_InsertColumn(item, 2, &lvc); LVITEM vitem; @@ -990,16 +998,12 @@ void CDialogAbout::CTabVersion::Initialize() m_Initialized = true; HWND item = GetDlgItem(m_Window, IDC_ABOUTVERSION_VERSION_TEXT); - WCHAR tmpSz[128]; - _snwprintf_s(tmpSz, _TRUNCATE, L"%s %s%s r%i %s (%s)", APPNAME, APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE); + WCHAR tmpSz[64]; + _snwprintf_s(tmpSz, _TRUNCATE, L"%s%s r%s %s (%s)", APPVERSION, revision_beta ? L" beta" : L"", REVISION, APPBITS, APPDATE); SetWindowText(item, tmpSz); item = GetDlgItem(m_Window, IDC_ABOUTVERSION_PATHS_TEXT); - std::wstring text = L"Path: " + Rainmeter->GetPath(); - text += L"\r\nSettings: "; - text += Rainmeter->GetSettingsPath(); - text += L"\r\nSkins: "; - text += Rainmeter->GetSkinPath(); + std::wstring text = GetFormattedString(ID_STR_PATHDETAILS, Rainmeter->GetPath().c_str(), Rainmeter->GetSettingsPath().c_str(), Rainmeter->GetSkinPath().c_str()); SetWindowText(item, text.c_str()); } @@ -1040,14 +1044,9 @@ INT_PTR CDialogAbout::CTabVersion::OnCommand(WPARAM wParam, LPARAM lParam) { case IDC_ABOUTVERSION_COPY_BUTTON: { - WCHAR tmpSz[128]; - _snwprintf_s(tmpSz, _TRUNCATE, L"%s %s%s r%i %s (%s)", APPNAME, APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE); - std::wstring text = tmpSz; - text += L"\r\nPath: " + Rainmeter->GetPath(); - text += L"\r\nSettings: "; - text += Rainmeter->GetSettingsPath(); - text += L"\r\nSkins: "; - text += Rainmeter->GetSkinPath(); + WCHAR tmpSz[64]; + _snwprintf_s(tmpSz, _TRUNCATE, L"%s%s r%i %s (%s)", APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE); + std::wstring text = GetFormattedString(ID_STR_PATHDETAILS, Rainmeter->GetPath().c_str(), Rainmeter->GetSettingsPath().c_str(), Rainmeter->GetSkinPath().c_str()); CSystem::SetClipboardText(text); } break; diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index 1a7687eb..0810e3ac 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -68,7 +68,7 @@ void CDialogManage::Open(int tab) { if (!c_Dialog) { - HINSTANCE instance = Rainmeter->GetInstance(); + HINSTANCE instance = Rainmeter->GetResourceInstance(); HWND owner = Rainmeter->GetTrayWindow()->GetWindow(); if (!CreateDialog(instance, MAKEINTRESOURCE(IDD_MANAGE_DIALOG), owner, DlgProc)) return; } @@ -202,17 +202,18 @@ 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 = L"Skins"; + tci.pszText = GetString(ID_STR_SKINS, tmpSz); TabCtrl_InsertItem(item, 0, &tci); - tci.pszText = L"Themes"; + tci.pszText = GetString(ID_STR_THEMES, tmpSz); TabCtrl_InsertItem(item, 1, &tci); - tci.pszText = L"Settings"; + tci.pszText = GetString(ID_STR_SETTINGS, tmpSz); TabCtrl_InsertItem(item, 2, &tci); - HINSTANCE instance = Rainmeter->GetInstance(); + HINSTANCE instance = Rainmeter->GetResourceInstance(); m_TabSkins = new CTabSkins(CreateDialog(instance, MAKEINTRESOURCE(IDD_MANAGESKINS_DIALOG), m_Window, CTabSkins::DlgProc)); m_TabThemes = new CTabThemes(CreateDialog(instance, MAKEINTRESOURCE(IDD_MANAGETHEMES_DIALOG), m_Window, CTabThemes::DlgProc)); m_TabSettings = new CTabSettings(CreateDialog(instance, MAKEINTRESOURCE(IDD_MANAGESETTINGS_DIALOG), m_Window, CTabSettings::DlgProc)); @@ -342,9 +343,16 @@ CDialogManage::CTabSkins::CTabSkins(HWND wnd) : CTab(wnd), void CDialogManage::CTabSkins::Initialize() { m_Initialized = true; - + + std::wstring tmpSz; + GetString(ID_STR_ACTIVESKINS, tmpSz); + if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA) + { + // Arrow down + tmpSz += L" \x25BE"; + } HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_ACTIVESKINS_BUTTON); - SetWindowText(item, L"Active skins \x25BE"); + SetWindowText(item, tmpSz.c_str()); // Load folder/.ini icons from shell32 HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32, 2, 10); @@ -371,7 +379,13 @@ void CDialogManage::CTabSkins::Initialize() ShowWindow(item, SW_HIDE); item = GetDlgItem(m_Window, IDC_MANAGESKINS_DISPLAYMONITOR_BUTTON); - SetWindowText(item, L"Display monitor \x25BE"); + GetString(ID_STR_DISPLAYMONITOR, tmpSz); + if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA) + { + // Arrow down + tmpSz += L" \x25BE"; + } + SetWindowText(item, tmpSz.c_str()); item = GetDlgItem(m_Window, IDC_MANAGESKINS_TRANSPARENCY_COMBOBOX); ComboBox_AddString(item, L"0%"); @@ -386,17 +400,17 @@ void CDialogManage::CTabSkins::Initialize() ComboBox_AddString(item, L"90%"); item = GetDlgItem(m_Window, IDC_MANAGESKINS_ZPOSITION_COMBOBOX); - ComboBox_AddString(item, L"On desktop"); - ComboBox_AddString(item, L"Bottom"); - ComboBox_AddString(item, L"Normal"); - ComboBox_AddString(item, L"Topmost"); - ComboBox_AddString(item, L"Stay topmost"); + 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)); item = GetDlgItem(m_Window, IDC_MANAGESKINS_ONHOVER_COMBOBOX); - ComboBox_AddString(item, L"Do nothing"); - ComboBox_AddString(item, L"Hide"); - ComboBox_AddString(item, L"Fade in"); - ComboBox_AddString(item, L"Fade out"); + 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)); m_HandleCommands = true; } @@ -464,7 +478,7 @@ void CDialogManage::CTabSkins::SetControls() if (m_SkinWindow) { - SetWindowText(item, L"Unload"); + SetWindowText(item, GetString(ID_STR_UNLOAD, buffer, 64)); item = GetDlgItem(m_Window, IDC_MANAGESKINS_REFRESH_BUTTON); EnableWindow(item, TRUE); @@ -532,14 +546,15 @@ void CDialogManage::CTabSkins::SetControls() } else { - SetWindowText(item, L"Load"); + SetWindowText(item, GetString(ID_STR_LOAD, buffer, 64)); } } void CDialogManage::CTabSkins::DisableControls(bool clear) { HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_LOAD_BUTTON); - SetWindowText(item, L"Load"); + WCHAR buffer[64]; + SetWindowText(item, GetString(ID_STR_LOAD, buffer, 64)); if (clear) { @@ -854,25 +869,23 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam) ++index; } - if (index == 0) + if (index > 0) { - InsertMenu(menu, index, MF_BYPOSITION | MF_GRAYED, 0, L"No active skins"); + RECT r; + GetWindowRect((HWND)lParam, &r); + + // Show context menu + TrackPopupMenu( + menu, + TPM_RIGHTBUTTON | TPM_LEFTALIGN, + r.left, + --r.bottom, + 0, + m_Window, + NULL + ); } - RECT r; - GetWindowRect((HWND)lParam, &r); - - // Show context menu - TrackPopupMenu( - menu, - TPM_RIGHTBUTTON | TPM_LEFTALIGN, - r.left, - --r.bottom, - 0, - m_Window, - NULL - ); - DestroyMenu(menu); } break; @@ -1007,7 +1020,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam) case IDC_MANAGESKINS_DISPLAYMONITOR_BUTTON: { - HMENU menu = LoadMenu(Rainmeter->GetInstance(), MAKEINTRESOURCE(IDR_SKIN_MENU)); + HMENU menu = LoadMenu(Rainmeter->GetResourceInstance(), MAKEINTRESOURCE(IDR_SKIN_MENU)); if (menu) { HMENU subMenu = GetSubMenu(menu, 0); // Skin menu @@ -1182,9 +1195,10 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam) tvi.hItem = TreeView_GetSelection(nm->hwndFrom); tvi.mask = TVIF_STATE; - HMENU menu = LoadMenu(Rainmeter->GetInstance(), MAKEINTRESOURCE(IDR_MANAGESKINS_MENU)); + 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); @@ -1198,7 +1212,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam) if (tvi.state & TVIS_EXPANDED) { - mii.dwTypeData = L"Collapse"; + mii.dwTypeData = GetString(ID_STR_COLLAPSE, tmpSz); SetMenuItemInfo(subMenu, ID_CONTEXT_MANAGESKINSMENU_EXPAND, MF_BYCOMMAND, &mii); } } @@ -1210,7 +1224,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam) if (m_SkinWindow) { - mii.dwTypeData = L"Unload"; + mii.dwTypeData = GetString(ID_STR_UNLOAD, tmpSz); SetMenuItemInfo(subMenu, ID_CONTEXT_MANAGESKINSMENU_LOAD, MF_BYCOMMAND, &mii); } else @@ -1407,9 +1421,8 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam) bool alreadyExists = (_waccess(path.c_str(), 0) != -1); if (alreadyExists) { - std::wstring question = L"A theme named \"" + theme; - question += L"\" already exists.\n\nDo you want to replace it?"; - if (MessageBox(NULL, question.c_str(), APPNAME, MB_ICONWARNING | MB_YESNO | MB_TOPMOST) != IDYES) + std::wstring text = GetFormattedString(ID_STR_THEMEALREADYEXISTS, theme.c_str()); + if (MessageBox(NULL, text.c_str(), APPNAME, MB_ICONWARNING | MB_YESNO | MB_TOPMOST) != IDYES) { // Cancel break; @@ -1428,8 +1441,8 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam) { if (!CSystem::CopyFiles(Rainmeter->GetIniFile(), path)) { - std::wstring message = L"Unable to save theme at: " + path; - MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR); + std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str()); + MessageBox(NULL, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR); break; } @@ -1472,8 +1485,8 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam) HANDLE file = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (file == INVALID_HANDLE_VALUE) { - std::wstring message = L"Unable to save theme at: " + path; - MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR); + std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str()); + MessageBox(NULL, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR); break; } @@ -1535,9 +1548,8 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam) int sel = ListBox_GetCurSel(item); std::vector& themes = const_cast&>(Rainmeter->GetAllThemes()); - std::wstring question = L"Are you sure you want to delete the \"" + themes[sel]; - question += L"\" theme?"; - if (MessageBox(NULL, question.c_str(), APPNAME, MB_ICONQUESTION | MB_YESNO | MB_TOPMOST) != IDYES) + std::wstring text = GetFormattedString(ID_STR_THEMEDELETE, themes[sel].c_str()); + if (MessageBox(NULL, text.c_str(), APPNAME, MB_ICONQUESTION | MB_YESNO | MB_TOPMOST) != IDYES) { // Cancel break; diff --git a/Library/Library.rc b/Library/Library.rc index ff9a3c1e..d99347bf 100644 --- a/Library/Library.rc +++ b/Library/Library.rc @@ -4,20 +4,6 @@ #include "resource.h" #include "../Version.h" -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "windows.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Finnish resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT #pragma code_page(1252) @@ -48,7 +34,7 @@ BEGIN VALUE "FileDescription", "Rainmeter Core Library" VALUE "FileVersion", STRFILEVER VALUE "InternalName", "Rainmeter" - VALUE "LegalCopyright", "Copyright (C) 2010 - Rainy" + VALUE "LegalCopyright", "Copyright (C) 2011 - All authors" VALUE "OriginalFilename", "Rainmeter.dll" VALUE "ProductName", "Rainmeter" #ifdef _WIN64 @@ -64,281 +50,6 @@ BEGIN END END -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_CONTEXT_MENU MENU -BEGIN - POPUP "Rainmeter" - BEGIN - MENUITEM "Manage", ID_CONTEXT_MANAGE - MENUITEM "About", ID_CONTEXT_ABOUT - MENUITEM "Help", ID_CONTEXT_SHOW_HELP - MENUITEM SEPARATOR - POPUP "Skins" - BEGIN - MENUITEM "No skins available", 0, GRAYED - MENUITEM SEPARATOR - MENUITEM "Open folder", ID_CONTEXT_OPENSKINSFOLDER - MENUITEM "Disable dragging", ID_CONTEXT_DISABLEDRAG - END - POPUP "Themes" - BEGIN - MENUITEM "No themes available", 0, GRAYED - END - MENUITEM SEPARATOR - MENUITEM "Edit settings", ID_CONTEXT_EDITCONFIG - MENUITEM "Refresh all", ID_CONTEXT_REFRESH - MENUITEM SEPARATOR - POPUP "Logging" - BEGIN - MENUITEM "Show log file", ID_CONTEXT_SHOWLOGFILE - MENUITEM SEPARATOR - MENUITEM "Start logging", ID_CONTEXT_STARTLOG - MENUITEM "Stop logging", ID_CONTEXT_STOPLOG - MENUITEM SEPARATOR - MENUITEM "Delete log file", ID_CONTEXT_DELETELOGFILE - MENUITEM "Debug mode", ID_CONTEXT_DEBUGLOG - END - MENUITEM SEPARATOR - MENUITEM "Exit", ID_CONTEXT_QUIT - END -END - -IDR_SKIN_MENU MENU -BEGIN - POPUP "Skin" - BEGIN - MENUITEM " ", ID_CONTEXT_SKINMENU_OPENSKINSFOLDER // Avoid to be compiled as a separator - MENUITEM SEPARATOR - POPUP "Variants" - BEGIN - MENUITEM SEPARATOR // DUMMY - END - MENUITEM SEPARATOR - POPUP "Settings" - BEGIN - POPUP "Position" - BEGIN - POPUP "Display monitor" - BEGIN - MENUITEM "Use default: Primary monitor", ID_CONTEXT_SKINMENU_MONITOR_PRIMARY - MENUITEM "@0: Virtual screen", ID_MONITOR_FIRST - MENUITEM SEPARATOR - MENUITEM SEPARATOR - MENUITEM "Auto-select based on window position", ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT - END - MENUITEM SEPARATOR - MENUITEM "Stay topmost", ID_CONTEXT_SKINMENU_VERYTOPMOST - MENUITEM "Topmost", ID_CONTEXT_SKINMENU_TOPMOST - MENUITEM "Normal", ID_CONTEXT_SKINMENU_NORMAL - MENUITEM "Bottom", ID_CONTEXT_SKINMENU_BOTTOM - MENUITEM "On desktop", ID_CONTEXT_SKINMENU_ONDESKTOP - MENUITEM SEPARATOR - MENUITEM "From right", ID_CONTEXT_SKINMENU_FROMRIGHT - MENUITEM "From bottom", ID_CONTEXT_SKINMENU_FROMBOTTOM - MENUITEM "X as percentage", ID_CONTEXT_SKINMENU_XPERCENTAGE - MENUITEM "Y as percentage", ID_CONTEXT_SKINMENU_YPERCENTAGE - END - POPUP "Transparency" - BEGIN - MENUITEM "0%", ID_CONTEXT_SKINMENU_TRANSPARENCY_0 - MENUITEM "10%", ID_CONTEXT_SKINMENU_TRANSPARENCY_10 - MENUITEM "20%", ID_CONTEXT_SKINMENU_TRANSPARENCY_20 - MENUITEM "30%", ID_CONTEXT_SKINMENU_TRANSPARENCY_30 - MENUITEM "40%", ID_CONTEXT_SKINMENU_TRANSPARENCY_40 - MENUITEM "50%", ID_CONTEXT_SKINMENU_TRANSPARENCY_50 - MENUITEM "60%", ID_CONTEXT_SKINMENU_TRANSPARENCY_60 - MENUITEM "70%", ID_CONTEXT_SKINMENU_TRANSPARENCY_70 - MENUITEM "80%", ID_CONTEXT_SKINMENU_TRANSPARENCY_80 - MENUITEM "90%", ID_CONTEXT_SKINMENU_TRANSPARENCY_90 - MENUITEM SEPARATOR - MENUITEM "Fade in", ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN - MENUITEM "Fade out", ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT - END - MENUITEM SEPARATOR - MENUITEM "Hide on mouse over", ID_CONTEXT_SKINMENU_HIDEONMOUSE - MENUITEM "Draggable", ID_CONTEXT_SKINMENU_DRAGGABLE - MENUITEM "Save position", ID_CONTEXT_SKINMENU_REMEMBERPOSITION - MENUITEM "Snap to edges", ID_CONTEXT_SKINMENU_SNAPTOEDGES - MENUITEM "Click through", ID_CONTEXT_SKINMENU_CLICKTHROUGH - MENUITEM "Keep on screen", ID_CONTEXT_SKINMENU_KEEPONSCREEN - END - MENUITEM SEPARATOR - MENUITEM "Manage skin", ID_CONTEXT_SKINMENU_MANAGESKIN - MENUITEM "Edit skin", ID_CONTEXT_SKINMENU_EDITSKIN - MENUITEM "Refresh skin", ID_CONTEXT_SKINMENU_REFRESH - MENUITEM SEPARATOR - MENUITEM "Unload skin", ID_CONTEXT_CLOSESKIN - END -END - -IDR_MANAGESKINS_MENU MENU -BEGIN - POPUP "Folder" - BEGIN - MENUITEM "Expand", ID_CONTEXT_MANAGESKINSMENU_EXPAND - MENUITEM "Open folder", ID_CONTEXT_MANAGESKINSMENU_OPENFOLDER - END - POPUP "Item" - BEGIN - MENUITEM "Load", ID_CONTEXT_MANAGESKINSMENU_LOAD - MENUITEM "Refresh", ID_CONTEXT_MANAGESKINSMENU_REFRESH - MENUITEM "Edit", ID_CONTEXT_MANAGESKINSMENU_EDIT - END -END - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// -IDD_ABOUT_DIALOG DIALOGEX 0, 0, 400, 210 -STYLE DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -EXSTYLE WS_EX_APPWINDOW| WS_EX_CONTROLPARENT -CAPTION "About Rainmeter" -FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 -BEGIN - CONTROL "", IDC_ABOUT_TAB, "SysTabControl32", TCS_TABS | TCS_FIXEDWIDTH, 6, 6, 388, 181 - DEFPUSHBUTTON "Close", IDCLOSE, 344, 191, 50, 14 -END - -IDD_ABOUTLOG_DIALOG DIALOGEX 15, 30, 370, 148 -STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS -FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 -BEGIN - CONTROL "", IDC_ABOUTLOG_ITEMS_LISTVIEW, "SysListView32", LVS_ICON | LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 0, 0, 368, 135 - AUTOCHECKBOX "Error", IDC_ABOUTLOG_ERROR_CHECKBOX, 0, 139, 50, 9 - AUTOCHECKBOX "Warning", IDC_ABOUTLOG_WARNING_CHECKBOX, 50, 139, 50, 9 - AUTOCHECKBOX "Notice", IDC_ABOUTLOG_NOTICE_CHECKBOX, 100, 139, 50, 9 - AUTOCHECKBOX "Debug", IDC_ABOUTLOG_DEBUG_CHECKBOX, 150, 139, 50, 9 -END - -IDD_ABOUTMEASURES_DIALOG DIALOGEX 15, 30, 370, 148 -STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS -FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 -BEGIN - LISTBOX IDC_ABOUTMEASURES_ITEMS_LISTBOX, 0, 0, 120, 148, LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP - CONTROL "", IDC_ABOUTMEASURES_ITEMS_LISTVIEW, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 125, 0, 242, 148 -END - -IDD_ABOUTPLUGINS_DIALOG DIALOGEX 15, 30, 370, 148 -STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS -FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 -BEGIN - CONTROL "", IDC_ABOUTPLUGINS_ITEMS_LISTVIEW, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 0, 0, 368, 148 -END - -IDD_ABOUTVERSION_DIALOG DIALOGEX 15, 30, 370, 148 -STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS -FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 -BEGIN - CONTROL IDI_WINDOW, IDC_STATIC, STATIC, SS_ICON | WS_CHILD | WS_VISIBLE, 0, 8, 24, 24 - LTEXT "", IDC_ABOUTVERSION_VERSION_TEXT, 28, 0, 300, 9 - CONTROL "Get the latest version at rainmeter.net.", IDC_STATIC, "SysLink", 0x0, 28, 13, 300, 9 - CONTROL "Distributed under the GNU GPL v2 license.", IDC_STATIC, "SysLink", 0x0, 28, 26, 300, 9 - LTEXT "", IDC_ABOUTVERSION_PATHS_TEXT, 0, 43, 300, 34 - PUSHBUTTON "Copy to clipboard", IDC_ABOUTVERSION_COPY_BUTTON, 0, 81, 80, 14, WS_TABSTOP -END - -IDD_MANAGE_DIALOG DIALOGEX 0, 0, 500, 322 -STYLE DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW | WS_EX_CONTROLPARENT -CAPTION "Manage Rainmeter" -FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 -BEGIN - CONTROL "", IDC_MANAGE_TAB, "SysTabControl32", TCS_TABS | TCS_FIXEDWIDTH, 6, 6, 488, 293 - PUSHBUTTON "Refresh all", IDC_REFRESHALL_BUTTON, 5, 303, 70, 14 - PUSHBUTTON "Edit settings", IDC_EDITSETTINGS_BUTTON, 79, 303, 70, 14 - PUSHBUTTON "Open log", IDC_OPENLOG_BUTTON, 153, 303, 70, 14 - PUSHBUTTON "Close", IDCLOSE, 444, 303, 50, 14 -END - -IDD_MANAGESKINS_DIALOG DIALOGEX 15, 30, 470, 260 -STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS -FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 -BEGIN - PUSHBUTTON "", IDC_MANAGESKINS_ACTIVESKINS_BUTTON, 0, 0, 145, 14, WS_TABSTOP - CONTROL "", IDC_MANAGESKINS_SKINS_TREEVIEW, "SysTreeView32", TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER | WS_VSCROLL, 0, 18, 145, 241 - - LTEXT "N/A", IDC_MANAGESKINS_FILE_TEXT, 165, 0, 130, 14, SS_ENDELLIPSIS | SS_NOPREFIX - LTEXT "N/A", IDC_MANAGESKINS_CONFIG_TEXT, 165, 15, 130, 9, SS_ENDELLIPSIS | SS_NOPREFIX - PUSHBUTTON "Load", IDC_MANAGESKINS_LOAD_BUTTON, 310, 0, 50, 14, WS_DISABLED | WS_TABSTOP - PUSHBUTTON "Refresh", IDC_MANAGESKINS_REFRESH_BUTTON, 364, 0, 50, 14, WS_DISABLED | WS_TABSTOP - PUSHBUTTON "Edit", IDC_MANAGESKINS_EDIT_BUTTON, 418, 0, 50, 14, WS_DISABLED | WS_TABSTOP - - LTEXT "Author:", IDC_STATIC, 165, 30, 80, 9 - LTEXT "", IDC_MANAGESKINS_AUTHOR_TEXT, 230, 30, 245, 9, SS_ENDELLIPSIS | SS_NOPREFIX - LTEXT "Version:", IDC_STATIC, 165, 43, 80, 9 - LTEXT "", IDC_MANAGESKINS_VERSION_TEXT, 230, 43, 245, 9, SS_ENDELLIPSIS | SS_NOPREFIX - LTEXT "License:", IDC_STATIC, 165, 56, 80, 9 - LTEXT "", IDC_MANAGESKINS_LICENSE_TEXT, 230, 56, 245, 9, SS_ENDELLIPSIS | SS_NOPREFIX - LTEXT "Information:", IDC_STATIC, 165, 69, 80, 9 - EDITTEXT IDC_MANAGESKINS_DESCRIPTION_TEXT, 228, 69, 238, 64, ES_MULTILINE | ES_READONLY - CONTROL "Add metadata", IDC_MANAGESKINS_ADDMETADATA_LINK, "SysLink", 0x0, 410, 142, 50, 9 - - CONTROL "", IDC_STATIC, STATIC, SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 165, 156, 304, 1 - LTEXT "Coordinates:", IDC_STATIC, 165, 169, 80, 9 - EDITTEXT IDC_MANAGESKINS_X_TEXT, 230, 166, 33, 14, WS_BORDER | WS_TABSTOP | WS_DISABLED - EDITTEXT IDC_MANAGESKINS_Y_TEXT, 267, 166, 33, 14, ES_NUMBER | WS_BORDER | WS_TABSTOP | WS_DISABLED - LTEXT "Position:", IDC_STATIC, 165, 190, 80, 9 - COMBOBOX IDC_MANAGESKINS_ZPOSITION_COMBOBOX, 230, 187, 70, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED - LTEXT "Load order:", IDC_STATIC, 165, 208, 80, 9 - EDITTEXT IDC_MANAGESKINS_LOADORDER_TEXT, 230, 205, 70, 14, WS_BORDER | WS_TABSTOP | WS_DISABLED - LTEXT "Transparency:", IDC_STATIC, 165, 229, 80, 9 - COMBOBOX IDC_MANAGESKINS_TRANSPARENCY_COMBOBOX, 230, 226, 70, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED - LTEXT "On hover:", IDC_STATIC, 165, 247, 80, 9 - COMBOBOX IDC_MANAGESKINS_ONHOVER_COMBOBOX, 230, 244, 70, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED - PUSHBUTTON "", IDC_MANAGESKINS_DISPLAYMONITOR_BUTTON, 330, 166, 90, 14, WS_DISABLED | WS_TABSTOP - AUTOCHECKBOX "Draggable", IDC_MANAGESKINS_DRAGGABLE_CHECKBOX, 330, 190, 80, 9, WS_DISABLED - AUTOCHECKBOX "Click through", IDC_MANAGESKINS_CLICKTHROUGH_CHECKBOX, 330, 203, 80, 9, WS_DISABLED - AUTOCHECKBOX "Keep on screen", IDC_MANAGESKINS_KEEPONSCREEN_CHECKBOX, 330, 216, 80, 9, WS_DISABLED - AUTOCHECKBOX "Save position", IDC_MANAGESKINS_SAVEPOSITION_CHECKBOX, 330, 229, 80, 9, WS_DISABLED - AUTOCHECKBOX "Snap to edges", IDC_MANAGESKINS_SNAPTOEDGES_CHECKBOX, 330, 242, 80, 9, WS_DISABLED -END - -IDD_MANAGETHEMES_DIALOG DIALOGEX 15, 30, 470, 260 -STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS -FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 -BEGIN - GROUPBOX "Save new theme", IDC_STATIC, 0, 0, 230, 150 - LTEXT "A theme allows you to save the current layout of your Rainmeter skins and restore it at a later time. Restoring an old theme will restore the layout, but will not not undo edits or updates to your skins.", IDC_STATIC, 6, 16, 205, 44 - AUTOCHECKBOX "Save as empty theme", IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX, 6, 70, 120, 9, WS_TABSTOP - AUTOCHECKBOX "Exclude unused skins", IDC_MANAGETHEMES_UNUSEDSKINS_CHECKBOX, 6, 83, 120, 9, WS_TABSTOP - AUTOCHECKBOX "Include current wallpaper", IDC_MANAGETHEMES_WALLPAPER_CHECKBOX, 6, 96, 120, 9, WS_TABSTOP - LTEXT "Name:", IDC_STATIC, 6, 115, 100, 9 - EDITTEXT IDC_MANAGETHEMES_NAME_TEXT, 6, 128, 160, 14, WS_BORDER | WS_TABSTOP - PUSHBUTTON "Save", IDC_MANAGETHEMES_SAVE_BUTTON, 170, 128, 50, 14, WS_DISABLED | WS_TABSTOP - - GROUPBOX "Saved themes", IDC_STATIC, 238, 0, 230, 150 - LISTBOX IDC_MANAGETHEMES_LIST, 244, 16, 160, 125, LBS_STANDARD | LBS_NOINTEGRALHEIGHT - PUSHBUTTON "Load", IDC_MANAGETHEMES_LOAD_BUTTON, 410, 16, 50, 14, WS_DISABLED - PUSHBUTTON "Delete", IDC_MANAGETHEMES_DELETE_BUTTON, 410, 34, 50, 14, WS_DISABLED - PUSHBUTTON "Edit", IDC_MANAGETHEMES_EDIT_BUTTON, 410, 52, 50, 14, WS_DISABLED - - GROUPBOX "Backup", IDC_STATIC, 0, 200, 468, 60 - LTEXT "A backup allows you to save and fully restore Rainmeter to a prior state, including skins, themes, plugins, addons and statistics. Unlike a theme, installing a backup will replace all edits and updates to your skins since the backup was saved.", IDC_STATIC, 6, 216, 455, 24 - PUSHBUTTON "Backup...", IDC_MANAGETHEMES_BACKUP_BUTTON, 410, 240, 50, 14 -END - -IDD_MANAGESETTINGS_DIALOG DIALOGEX 15, 30, 470, 260 -STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS -FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 -BEGIN - GROUPBOX "General", IDC_STATIC, 0, 0, 468, 68 - //AUTOCHECKBOX "Run automatically at startup", IDC_MANAGESETTINGS_AUTOSTART_CHECKBOX, 6, 16, 140, 9, WS_DISABLED - AUTOCHECKBOX "Check for updates", IDC_MANAGESETTINGS_CHECKUPDATES_CHECKBOX, 6, 16, 140, 9 - AUTOCHECKBOX "Lock skins into position", IDC_MANAGESETTINGS_LOCKSKINS_CHECKBOX, 6, 29, 140, 9 - PUSHBUTTON "Reset statistics", IDC_MANAGESETTINGS_RESETSTATISTICS_BUTTON, 6, 47, 70, 14 - - GROUPBOX "Logging", IDC_STATIC, 0, 75, 468, 68 - AUTOCHECKBOX "Log to file", IDC_MANAGESETTINGS_LOGTOFILE_CHECKBOX, 6, 91, 140, 9 - AUTOCHECKBOX "Verbose logging (debug mode)", IDC_MANAGESETTINGS_VERBOSELOGGING_CHECKBOX, 6, 104, 140, 9 - PUSHBUTTON "Show log file", IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON, 6, 122, 70, 14 - PUSHBUTTON "Delete log file", IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON, 80, 122, 70, 14 -END - ///////////////////////////////////////////////////////////////////////////// // // Icon @@ -348,18 +59,3 @@ END // remains consistent on all systems. IDI_TRAY ICON DISCARDABLE "res\\tray.ico" IDI_WINDOW ICON DISCARDABLE "res\\window.ico" -#endif // Finnish resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/Library/Litestep.cpp b/Library/Litestep.cpp index 9d5a4821..879c9645 100644 --- a/Library/Litestep.cpp +++ b/Library/Litestep.cpp @@ -701,7 +701,7 @@ void Log(int nLevel, const WCHAR* message, const WCHAR* module) } } -void LogWithArgs(int nLevel, const WCHAR* format, ... ) +void LogWithArgs(int nLevel, const WCHAR* format, ...) { WCHAR* buffer = new WCHAR[4096]; va_list args; @@ -732,6 +732,50 @@ 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) +{ + 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(); +} + +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), + 0, + 0, + (LPWSTR)&pBuffer, + 0, + &args); + + va_end(args); + + tmpSz = pBuffer; + LocalFree(pBuffer); + return tmpSz; +} + void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved) { // Do nothing. diff --git a/Library/Litestep.h b/Library/Litestep.h index 8837edd4..6443f10a 100644 --- a/Library/Litestep.h +++ b/Library/Litestep.h @@ -62,7 +62,11 @@ 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); +std::wstring GetFormattedString(UINT id, ...); + HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd); HINSTANCE ExecuteCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, LPCTSTR szVerb); -#endif \ No newline at end of file +#endif diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 3b7dd521..5016eadf 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1721,6 +1721,7 @@ CRainmeter::CRainmeter() : m_Logging(false), m_CurrentParser(), m_Instance(), + m_ResourceInstance(), m_GDIplusToken() { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); @@ -1780,7 +1781,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath) if (Parent == NULL || Instance == NULL) { - throw CError(L"Null parameter", __LINE__, __FILE__); + throw CError(L"Null parameter"); } m_Instance = Instance; @@ -1801,6 +1802,13 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath) m_Path = tmpSzPath; + wcscat(tmpSzPath, L"Language.dll"); + m_ResourceInstance = LoadLibraryEx(tmpSzPath, NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE); + if (!m_ResourceInstance) + { + throw CError(L"Unable to load Language.dll"); + } + InitalizeLitestep(); bool bDefaultIniLocation = false; @@ -2033,7 +2041,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath) if (m_ConfigStrings.empty()) { - std::wstring error = L"There are no available skins at:\n" + m_SkinPath; + std::wstring error = GetFormattedString(ID_STR_NOAVAILABLESKINS, m_SkinPath.c_str()); MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR); } @@ -2218,10 +2226,7 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex) if (_waccess(skinIniPath.c_str(), 0) == -1) { - std::wstring message = L"Unable to activate skin \"" + skinConfig; - message += L"\\"; - message += skinIniFile; - message += L"\": File not found"; + std::wstring message = GetFormattedString(ID_STR_UNABLETOACTIVATESKIN, skinConfig.c_str(), skinIniFile.c_str()); MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); return; } @@ -3385,10 +3390,7 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile) { if (!SetActiveConfig(skinName, skinIni)) { - std::wstring error = L"The selected skin (L" + skinName; - error += L"\\"; - error += skinIni; - error += L") cannot be found."; + std::wstring error = GetFormattedString(ID_STR_UNABLETOACTIVATESKIN, skinName.c_str(), skinIni.c_str()); MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); } return; @@ -3522,11 +3524,8 @@ void CRainmeter::RefreshAll() { DeactivateConfig(mw, i); - std::wstring message = L"Unable to refresh skin \"" + skinConfig; - message += L"\\"; - message += skinIniFile; - message += L"\": File not found."; - MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); + std::wstring error = GetFormattedString(ID_STR_UNABLETOREFRESHSKIN, skinConfig.c_str(), skinIniFile.c_str()); + MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); } break; } @@ -3538,9 +3537,8 @@ void CRainmeter::RefreshAll() { DeactivateConfig(mw, -2); // -2 = Deactivate the config forcibly - std::wstring message = L"Unable to refresh config \"" + skinConfig; - message += L"\": Config not found."; - MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); + std::wstring error = GetFormattedString(ID_STR_UNABLETOREFRESHSKIN, skinConfig.c_str(), L""); + MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); } continue; } @@ -3819,7 +3817,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow) m_MenuActive = true; // Show context menu, if no actions were executed - HMENU menu = LoadMenu(m_Instance, MAKEINTRESOURCE(IDR_CONTEXT_MENU)); + HMENU menu = LoadMenu(m_ResourceInstance, MAKEINTRESOURCE(IDR_CONTEXT_MENU)); if (menu) { @@ -3907,7 +3905,8 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow) // Put Update notifications in the Tray menu if (m_NewVersion) { - InsertMenu(subMenu, 0, MF_BYPOSITION, ID_CONTEXT_NEW_VERSION, L"Update available"); + std::wstring tmpSz; + InsertMenu(subMenu, 0, MF_BYPOSITION, ID_CONTEXT_NEW_VERSION, GetString(ID_STR_UPDATEAVAILABLE, tmpSz)); HiliteMenuItem(Rainmeter->GetTrayWindow()->GetWindow(), subMenu, 0, MF_BYPOSITION | MF_HILITE); InsertMenu(subMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); } @@ -4011,7 +4010,7 @@ void CRainmeter::CreateThemeMenu(HMENU themeMenu) HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU configMenu) { - HMENU skinMenu = LoadMenu(m_Instance, MAKEINTRESOURCE(IDR_SKIN_MENU)); + HMENU skinMenu = LoadMenu(m_ResourceInstance, MAKEINTRESOURCE(IDR_SKIN_MENU)); if (skinMenu) { @@ -4304,17 +4303,17 @@ void CRainmeter::StartLogging() ResetLoggingFlag(); // Re-enable logging SetLogging(true); - std::wstring message = L"Log file created at: " + m_LogFile; - MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONINFORMATION); + std::wstring text = GetFormattedString(ID_STR_LOGFILECREATED, m_LogFile.c_str()); + MessageBox(NULL, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONINFORMATION); } else { // Disable logging SetLogging(false); ResetLoggingFlag(); - - std::wstring message = L"Unable to create log file: " + m_LogFile; - MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR); + + std::wstring text = GetFormattedString(ID_STR_LOGFILECREATEFAIL, m_LogFile.c_str()); + MessageBox(NULL, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR); } } else @@ -4333,8 +4332,8 @@ void CRainmeter::DeleteLogFile() // Check if the file exists if (_waccess(m_LogFile.c_str(), 0) != -1) { - std::wstring message = L"Do you want to delete the following log file?\n" + m_LogFile; - int res = MessageBox(NULL, message.c_str(), APPNAME, MB_YESNO | MB_TOPMOST | MB_ICONQUESTION); + std::wstring text = GetFormattedString(ID_STR_LOGFILEDELETE, m_LogFile.c_str()); + int res = MessageBox(NULL, text.c_str(), APPNAME, MB_YESNO | MB_TOPMOST | MB_ICONQUESTION); if (res == IDYES) { // Disable logging @@ -4397,27 +4396,19 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation) } if (!bSuccess) { - std::wstring error = L"Rainmeter.ini is not writable. Rainmeter will not\n" - L"be able to save any settings permanently.\n\n"; + std::wstring error; + GetString(ID_STR_SETTINGSNOTWRITABLE, error); if (!bDefaultIniLocation) { std::wstring strTarget = L"%APPDATA%\\Rainmeter\\"; ExpandEnvironmentVariables(strTarget); - error += L"You should quit Rainmeter and move the settings file from\n"; - error += m_IniFile; - error += L"\n\nto\n"; - error += strTarget; - error += L"\n\nAlternatively, simply remove the file and it will\n" - L"be automatically recreated in the correct location on\n" - L"next launch (current settings will be lost)."; + error += GetFormattedString(ID_STR_SETTINGSMOVEFILE, m_IniFile.c_str(), strTarget.c_str()); } else { - error += L"Make sure that the settings file is not set as read-only and that\n" - L"the folder is writable. The file is located at:\n"; - error += m_IniFile; + error += GetFormattedString(ID_STR_SETTINGSREADONLY, m_IniFile.c_str()); } MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_ICONERROR); diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index 8ff8f1cc..696e7441 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -206,6 +206,7 @@ public: const std::wstring& GetStatsDate() { return m_StatsDate; } HINSTANCE GetInstance() { return m_Instance; } + HINSTANCE GetResourceInstance() { return m_ResourceInstance; } static void SetDummyLitestep(bool Dummy) { c_DummyLitestep = Dummy; } static bool GetDummyLitestep() { return c_DummyLitestep; } @@ -342,6 +343,7 @@ private: CConfigParser* m_CurrentParser; HINSTANCE m_Instance; + HMODULE m_ResourceInstance; ULONG_PTR m_GDIplusToken; diff --git a/Library/resource.h b/Library/resource.h index 38889e38..1b158446 100644 --- a/Library/resource.h +++ b/Library/resource.h @@ -140,3 +140,48 @@ #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 + diff --git a/Rainmeter.sln b/Rainmeter.sln index 598e145c..a6f6d632 100644 --- a/Rainmeter.sln +++ b/Rainmeter.sln @@ -2,6 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual C++ Express 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Application", "Application\Application.vcxproj", "{D2A0903C-E760-4134-AE61-3D55BF8F760C}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Language", "Language\Language.vcxproj", "{6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Library", "Library\Library.vcxproj", "{BE9D2400-7F1C-49D6-8498-5CE495491AD6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginAdvancedCPU", "Plugins\PluginAdvancedCPU\PluginAdvancedCPU.vcxproj", "{EE8EC522-8430-4B46-86A3-D943D77F9E4B}" @@ -60,6 +62,14 @@ Global {D2A0903C-E760-4134-AE61-3D55BF8F760C}.Release|Win32.Build.0 = Release|Win32 {D2A0903C-E760-4134-AE61-3D55BF8F760C}.Release|x64.ActiveCfg = Release|x64 {D2A0903C-E760-4134-AE61-3D55BF8F760C}.Release|x64.Build.0 = Release|x64 + {6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}.Debug|Win32.ActiveCfg = Debug|Win32 + {6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}.Debug|Win32.Build.0 = Debug|Win32 + {6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}.Debug|x64.ActiveCfg = Release|x64 + {6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}.Debug|x64.Build.0 = Release|x64 + {6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}.Release|Win32.ActiveCfg = Release|Win32 + {6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}.Release|Win32.Build.0 = Release|Win32 + {6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}.Release|x64.ActiveCfg = Release|x64 + {6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}.Release|x64.Build.0 = Release|x64 {BE9D2400-7F1C-49D6-8498-5CE495491AD6}.Debug|Win32.ActiveCfg = Debug|Win32 {BE9D2400-7F1C-49D6-8498-5CE495491AD6}.Debug|Win32.Build.0 = Debug|Win32 {BE9D2400-7F1C-49D6-8498-5CE495491AD6}.Debug|x64.ActiveCfg = Debug|x64 @@ -221,6 +231,7 @@ Global {F32FA418-8DF4-4E94-B92B-EBD502F5DC07}.Release|x64.ActiveCfg = Release|x64 {F32FA418-8DF4-4E94-B92B-EBD502F5DC07}.Release|x64.Build.0 = Release|x64 {C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Debug|Win32.ActiveCfg = Debug|Win32 + {C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Debug|Win32.Build.0 = Debug|Win32 {C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Debug|x64.ActiveCfg = Debug|x64 {C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Release|Win32.ActiveCfg = Release|Win32 {C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Release|x64.ActiveCfg = Release|x64