Minor tweaks and cleanup.

This commit is contained in:
Birunthan Mohanathas 2011-12-09 08:40:19 +00:00
parent 2835739b12
commit 13b3241307
9 changed files with 28 additions and 53 deletions

View File

@ -366,7 +366,7 @@ void CDialogAbout::CTabLog::Initialize()
// Set folder/.ini icons for tree list // Set folder/.ini icons for tree list
HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32, 2, 10); HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32, 2, 10);
HMODULE hDLL = LoadLibrary(L"user32.dll"); HMODULE hDLL = GetModuleHandle(L"user32");
HICON hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(103), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); HICON hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(103), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ImageList_AddIcon(hImageList, hIcon); ImageList_AddIcon(hImageList, hIcon);
@ -380,8 +380,6 @@ void CDialogAbout::CTabLog::Initialize()
ImageList_AddIcon(hImageList, hIcon); ImageList_AddIcon(hImageList, hIcon);
DeleteObject(hIcon); DeleteObject(hIcon);
FreeLibrary(hDLL);
ListView_SetImageList(item, (WPARAM)hImageList, LVSIL_SMALL); ListView_SetImageList(item, (WPARAM)hImageList, LVSIL_SMALL);
LVCOLUMN lvc; LVCOLUMN lvc;
@ -757,7 +755,7 @@ void CDialogAbout::CTabMeasures::UpdateMeasureList(CMeterWindow* meterWindow)
range += buffer; range += buffer;
ListView_SetItemText(item, index, 1, (WCHAR*)range.c_str()); ListView_SetItemText(item, index, 1, (WCHAR*)range.c_str());
ListView_SetItemText(item, index, 2, (WCHAR*)(*j)->GetStats()); ListView_SetItemText(item, index, 2, (WCHAR*)(*j)->GetStringValue(AUTOSCALE_OFF, 1, -1, false));
++index; ++index;
} }

View File

@ -369,15 +369,13 @@ void CDialogManage::CTabSkins::Initialize()
// Load folder/.ini icons from shell32 // Load folder/.ini icons from shell32
HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32, 2, 10); HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32, 2, 10);
HMODULE hDLL = LoadLibrary(L"shell32.dll"); HMODULE hDLL = GetModuleHandle(L"shell32");
HICON hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(4), IMAGE_ICON, 16, 16, LR_SHARED); HICON hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(4), IMAGE_ICON, 16, 16, LR_SHARED);
ImageList_AddIcon(hImageList, hIcon); ImageList_AddIcon(hImageList, hIcon);
hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(151), IMAGE_ICON, 16, 16, LR_SHARED); hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(151), IMAGE_ICON, 16, 16, LR_SHARED);
ImageList_AddIcon(hImageList, hIcon); ImageList_AddIcon(hImageList, hIcon);
FreeLibrary(hDLL);
// Apply icons and populate tree // Apply icons and populate tree
item = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW); item = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
TreeView_SetImageList(item, hImageList, TVSIL_NORMAL); TreeView_SetImageList(item, hImageList, TVSIL_NORMAL);
@ -1394,10 +1392,10 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
if (HIWORD(wParam) == EN_CHANGE) if (HIWORD(wParam) == EN_CHANGE)
{ {
WCHAR buffer[32]; WCHAR buffer[32];
Edit_GetText((HWND)lParam, buffer, 32); int len = Edit_GetText((HWND)lParam, buffer, 32);
// Disable save button if no text or if name is "Backup" // Disable save button if no text or if name is "Backup"
BOOL state = (wcslen(buffer) != 0 && _wcsicmp(buffer, L"Backup") != 0); BOOL state = (len > 0 && _wcsicmp(buffer, L"Backup") != 0);
EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_SAVE_BUTTON), state); EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_SAVE_BUTTON), state);
} }
break; break;

View File

@ -759,16 +759,6 @@ void CMeasure::RemoveTrailingZero(WCHAR* str, int strLen)
} }
} }
/*
** GetStats
**
** Returns the stats as string. The stats are shown in the About dialog.
*/
const WCHAR* CMeasure::GetStats()
{
return GetStringValue(AUTOSCALE_OFF, 1, -1, false);
}
/* /*
** Create ** Create
** **

View File

@ -52,8 +52,6 @@ public:
virtual void Initialize(); virtual void Initialize();
virtual bool Update() = 0; virtual bool Update() = 0;
virtual const WCHAR* GetStats();
const WCHAR* GetName() { return m_Name.c_str(); } const WCHAR* GetName() { return m_Name.c_str(); }
const std::wstring& GetOriginalName() { return m_Name; } const std::wstring& GetOriginalName() { return m_Name; }
const char* GetAsciiName() { return m_AsciiName.c_str(); } const char* GetAsciiName() { return m_AsciiName.c_str(); }

View File

@ -20,8 +20,6 @@
#include "MeasureCalc.h" #include "MeasureCalc.h"
#include "Rainmeter.h" #include "Rainmeter.h"
using namespace std;
hqStrMap* CMeasureCalc::c_VarMap = NULL; hqStrMap* CMeasureCalc::c_VarMap = NULL;
bool CMeasureCalc::c_RandSeeded = false; bool CMeasureCalc::c_RandSeeded = false;

View File

@ -635,9 +635,7 @@ bool CMeter::ReplaceMeasures(const std::vector<std::wstring>& stringValues, std:
// Create the actual text (i.e. replace %1, %2, .. with the measure texts) // Create the actual text (i.e. replace %1, %2, .. with the measure texts)
for (size_t i = stringValues.size(); i > 0; --i) for (size_t i = stringValues.size(); i > 0; --i)
{ {
_snwprintf_s(buffer, _TRUNCATE, L"%%%i", (int)i); size_t len = _snwprintf_s(buffer, _TRUNCATE, L"%%%i", (int)i);
size_t len = wcslen(buffer);
size_t start = 0, pos; size_t start = 0, pos;
do do
{ {

View File

@ -1157,16 +1157,13 @@ void CSystem::SetClipboardText(const std::wstring& text)
if (hMem) if (hMem)
{ {
LPVOID data = GlobalLock(hMem); LPVOID data = GlobalLock(hMem);
if (data) memcpy(data, text.c_str(), len * sizeof(WCHAR));
{ GlobalUnlock(hMem);
memcpy(data, text.c_str(), len * sizeof(WCHAR));
GlobalUnlock(hMem);
EmptyClipboard(); EmptyClipboard();
if (!SetClipboardData(CF_UNICODETEXT, hMem)) if (!SetClipboardData(CF_UNICODETEXT, hMem))
{ {
GlobalFree(hMem); GlobalFree(hMem);
}
} }
} }

View File

@ -410,20 +410,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
static CTrayWindow* tray = NULL; CTrayWindow* tray = Rainmeter->GetTrayWindow();
if (uMsg == WM_CREATE)
{
tray=(CTrayWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams;
}
else if (uMsg == WM_TASKBARCREATED)
{
if (tray && tray->IsTrayIconEnabled())
{
tray->RemoveTrayIcon();
tray->AddTrayIcon();
}
}
switch (uMsg) switch (uMsg)
{ {
@ -778,15 +765,15 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_COPYDATA: case WM_COPYDATA:
{ {
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam; COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lParam;
if (cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE) if (cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE)
{ {
std::wstring SkinName((LPTSTR) cds->lpData); std::wstring SkinName((LPTSTR)cds->lpData);
std::map<std::wstring, CMeterWindow*> MeterWindows = Rainmeter->GetAllMeterWindows(); std::map<std::wstring, CMeterWindow*> MeterWindows = Rainmeter->GetAllMeterWindows();
std::map<std::wstring, CMeterWindow*>::const_iterator iter = MeterWindows.find(SkinName); std::map<std::wstring, CMeterWindow*>::const_iterator iter = MeterWindows.find(SkinName);
if (iter != MeterWindows.end()) if (iter != MeterWindows.end())
{ {
return (LRESULT) iter->second->GetWindow(); return (LRESULT)iter->second->GetWindow();
} }
return NULL; return NULL;
} }
@ -818,6 +805,17 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_DESTROY: case WM_DESTROY:
PostQuitMessage(0); PostQuitMessage(0);
break; break;
default:
if (uMsg == WM_TASKBARCREATED)
{
if (tray && tray->IsTrayIconEnabled())
{
tray->RemoveTrayIcon();
tray->AddTrayIcon();
}
}
break;
} }
return DefWindowProc(hWnd, uMsg, wParam, lParam); return DefWindowProc(hWnd, uMsg, wParam, lParam);