2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000 Kimmo Pekkola
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2009-10-07 16:45:14 +00:00
|
|
|
#include "StdAfx.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "Rainmeter.h"
|
2010-09-11 19:39:45 +00:00
|
|
|
#include "System.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "MeterWindow.h"
|
|
|
|
#include "Measure.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "AboutDialog.h"
|
2011-02-03 15:52:45 +00:00
|
|
|
#include "../Version.h"
|
2010-08-30 22:51:58 +00:00
|
|
|
|
|
|
|
#define LOGTIMER 1
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-02-05 07:48:29 +00:00
|
|
|
#define WM_DELAYED_CLOSE WM_APP + 0
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
extern CRainmeter* Rainmeter;
|
|
|
|
|
|
|
|
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
2010-08-30 22:51:58 +00:00
|
|
|
void UpdateWidgets();
|
|
|
|
BOOL OnInitAboutDialog(HWND window);
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
HWND g_DialogWin = NULL;
|
2011-01-31 07:08:43 +00:00
|
|
|
WINDOWPLACEMENT g_DialogPlacement = {0};
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
struct PLUGIN_INFO
|
|
|
|
{
|
|
|
|
std::wstring name;
|
|
|
|
UINT version;
|
|
|
|
std::wstring author;
|
|
|
|
};
|
|
|
|
std::vector<PLUGIN_INFO> g_Plugins;
|
|
|
|
|
|
|
|
HWND OpenAboutDialog(HWND hwndOwner, HINSTANCE instance)
|
|
|
|
{
|
|
|
|
if (g_DialogWin == NULL)
|
|
|
|
{
|
|
|
|
g_DialogWin = CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUT_DIALOG), hwndOwner, AboutProc);
|
2011-01-30 16:21:00 +00:00
|
|
|
|
2010-08-25 14:36:20 +00:00
|
|
|
if (g_DialogWin)
|
|
|
|
{
|
|
|
|
HICON hIcon = LoadIcon(instance, MAKEINTRESOURCE(IDI_TRAY));
|
|
|
|
SendMessage(g_DialogWin, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
2011-01-31 07:08:43 +00:00
|
|
|
|
|
|
|
if (g_DialogPlacement.length == 0)
|
|
|
|
{
|
|
|
|
g_DialogPlacement.length = sizeof(WINDOWPLACEMENT);
|
|
|
|
GetWindowPlacement(g_DialogWin, &g_DialogPlacement);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowPlacement(g_DialogWin, &g_DialogPlacement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!IsZoomed(g_DialogWin))
|
|
|
|
{
|
|
|
|
ShowWindow(g_DialogWin, SW_SHOWNORMAL);
|
2010-08-25 14:36:20 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
UpdateAboutStatistics();
|
|
|
|
|
|
|
|
return g_DialogWin;
|
|
|
|
}
|
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
void UpdateAboutDialog()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (g_DialogWin != NULL && IsWindowVisible(g_DialogWin))
|
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
WCHAR* selectedItemName = NULL;
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
HWND widget;
|
2010-08-26 20:50:36 +00:00
|
|
|
widget = GetDlgItem(g_DialogWin, IDC_ABOUT_ENTRIES);
|
2010-08-30 22:51:58 +00:00
|
|
|
int selected = (int)SendMessage(widget, LB_GETCURSEL, 0, 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
// Get current selected entry
|
|
|
|
if (selected != 0 && selected != 1 && selected != LB_ERR)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
int selectedItemLen = (int)SendMessage(widget, LB_GETTEXTLEN, selected, 0);
|
2010-08-26 20:50:36 +00:00
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
if (selectedItemLen != LB_ERR)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
selectedItemName = new WCHAR[selectedItemLen + 1];
|
|
|
|
|
|
|
|
if (LB_ERR != SendMessage(widget, LB_GETTEXT, selected, (LPARAM)selectedItemName))
|
2010-08-26 20:50:36 +00:00
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
selectedItemName[selectedItemLen] = L'\0';
|
2010-08-26 20:50:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
delete [] selectedItemName;
|
|
|
|
selectedItemName = NULL;
|
2010-08-26 20:50:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-30 22:51:58 +00:00
|
|
|
|
|
|
|
// Delete all entries
|
|
|
|
SendMessage(widget, LB_RESETCONTENT, 0, 0);
|
|
|
|
|
|
|
|
// Update all dialog widgets
|
|
|
|
OnInitAboutDialog(g_DialogWin);
|
|
|
|
|
|
|
|
// Re-select entry
|
|
|
|
if (selected == 0 || selected == 1)
|
2010-08-26 20:50:36 +00:00
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
SendMessage(widget, LB_SETCURSEL, selected, 0);
|
|
|
|
UpdateWidgets();
|
2010-08-26 20:50:36 +00:00
|
|
|
}
|
2010-08-30 22:51:58 +00:00
|
|
|
else if (selectedItemName != NULL)
|
2010-08-26 20:50:36 +00:00
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
int sel = 3;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-01-24 10:15:05 +00:00
|
|
|
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
2010-08-26 20:50:36 +00:00
|
|
|
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
|
|
|
for( ; iter != windows.end(); ++iter)
|
|
|
|
{
|
2010-09-17 08:47:22 +00:00
|
|
|
if (_wcsicmp(selectedItemName, (*iter).first.c_str()) == 0)
|
2010-08-30 22:51:58 +00:00
|
|
|
{
|
|
|
|
SendMessage(widget, LB_SETCURSEL, sel, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++sel;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete [] selectedItemName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateAboutStatistics(LPCTSTR entryName)
|
|
|
|
{
|
|
|
|
if (g_DialogWin != NULL && IsWindowVisible(g_DialogWin))
|
|
|
|
{
|
|
|
|
HWND widget;
|
|
|
|
widget = GetDlgItem(g_DialogWin, IDC_ABOUT_ENTRIES);
|
|
|
|
int selected = (int)SendMessage(widget, LB_GETCURSEL, NULL, NULL);
|
|
|
|
int count = (int)SendMessage(widget, LB_GETCOUNT, NULL, NULL);
|
|
|
|
|
|
|
|
if (selected != LB_ERR)
|
|
|
|
{
|
|
|
|
widget = GetDlgItem(g_DialogWin, IDC_STATISTICS);
|
|
|
|
SendMessage(widget, WM_SETREDRAW, 0, 0);
|
|
|
|
|
|
|
|
if (selected == 0)
|
|
|
|
{
|
|
|
|
if (entryName == NULL)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-08-26 20:50:36 +00:00
|
|
|
int count = ListView_GetItemCount(widget);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-09-19 09:21:25 +00:00
|
|
|
std::list<CRainmeter::LOG_INFO>::const_iterator iter = Rainmeter->GetAboutLogData().begin();
|
2010-08-30 22:51:58 +00:00
|
|
|
LVITEM vitem;
|
|
|
|
vitem.mask = LVIF_TEXT;
|
2010-08-26 20:50:36 +00:00
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
int i = 0;
|
2010-09-19 09:21:25 +00:00
|
|
|
for ( ; iter != Rainmeter->GetAboutLogData().end(); ++iter)
|
2010-08-26 20:50:36 +00:00
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
if (i < count)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-01-31 07:08:43 +00:00
|
|
|
ListView_SetItemText(widget, i, 0, (WCHAR*)(*iter).timestamp.c_str());
|
2010-08-30 22:51:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vitem.iItem = i;
|
|
|
|
vitem.iSubItem = 0;
|
2011-01-31 07:08:43 +00:00
|
|
|
vitem.pszText = (WCHAR*)(*iter).timestamp.c_str();
|
2010-08-30 22:51:58 +00:00
|
|
|
ListView_InsertItem(widget, &vitem);
|
|
|
|
}
|
2011-01-31 07:08:43 +00:00
|
|
|
ListView_SetItemText(widget, i, 1, (WCHAR*)(*iter).type.c_str());
|
2010-08-30 22:51:58 +00:00
|
|
|
ListView_SetItemText(widget, i, 2, (WCHAR*)(*iter).message.c_str());
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (selected == 2)
|
|
|
|
{
|
|
|
|
HWND widgetEnt;
|
|
|
|
widgetEnt = GetDlgItem(g_DialogWin, IDC_ABOUT_ENTRIES);
|
|
|
|
SendMessage(widgetEnt, LB_SETCURSEL, 1, NULL);
|
|
|
|
UpdateWidgets();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int current = 3;
|
|
|
|
|
2011-01-24 10:15:05 +00:00
|
|
|
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
2010-08-30 22:51:58 +00:00
|
|
|
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
|
|
|
for( ; iter != windows.end(); ++iter)
|
|
|
|
{
|
|
|
|
if (current == selected)
|
|
|
|
{
|
2010-09-17 08:47:22 +00:00
|
|
|
if (entryName == NULL || _wcsicmp(entryName, (*iter).first.c_str()) == 0)
|
2010-08-30 22:51:58 +00:00
|
|
|
{
|
|
|
|
int count = ListView_GetItemCount(widget);
|
|
|
|
|
|
|
|
CMeterWindow* meterWindow = (*iter).second;
|
2011-01-24 10:15:05 +00:00
|
|
|
const std::list<CMeasure*>& measures = meterWindow->GetMeasures();
|
2010-08-30 22:51:58 +00:00
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
std::list<CMeasure*>::const_iterator i = measures.begin();
|
|
|
|
for( ; i != measures.end(); ++i)
|
2010-08-26 20:50:36 +00:00
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
const WCHAR* name = (*i)->GetName();
|
|
|
|
const WCHAR* val = (*i)->GetStats();
|
|
|
|
|
|
|
|
WCHAR buffer[256];
|
|
|
|
double minVal = (*i)->GetMinValue();
|
|
|
|
double maxVal = (*i)->GetMaxValue();
|
2011-01-19 15:31:45 +00:00
|
|
|
CMeasure::GetScaledValue(AUTOSCALE_ON, 1, minVal, buffer, _countof(buffer));
|
2010-11-11 20:24:59 +00:00
|
|
|
std::wstring range = buffer;
|
2010-08-30 22:51:58 +00:00
|
|
|
range += L" - ";
|
2011-01-19 15:31:45 +00:00
|
|
|
CMeasure::GetScaledValue(AUTOSCALE_ON, 1, maxVal, buffer, _countof(buffer));
|
2010-08-30 22:51:58 +00:00
|
|
|
range += buffer;
|
|
|
|
|
2010-11-25 15:34:49 +00:00
|
|
|
if (name && *name)
|
2010-08-30 22:51:58 +00:00
|
|
|
{
|
|
|
|
if (index < count)
|
|
|
|
{
|
|
|
|
ListView_SetItemText(widget, index, 0, (WCHAR*)name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LVITEM vitem;
|
|
|
|
vitem.mask = LVIF_TEXT;
|
|
|
|
vitem.iItem = index;
|
|
|
|
vitem.iSubItem = 0;
|
|
|
|
vitem.pszText = (WCHAR*)name;
|
|
|
|
ListView_InsertItem(widget, &vitem);
|
|
|
|
}
|
|
|
|
|
2011-01-31 07:08:43 +00:00
|
|
|
ListView_SetItemText(widget, index, 1, (WCHAR*)range.c_str());
|
2010-09-21 09:18:19 +00:00
|
|
|
if (val)
|
2010-08-30 22:51:58 +00:00
|
|
|
{
|
2011-01-31 07:08:43 +00:00
|
|
|
ListView_SetItemText(widget, index, 2, (WCHAR*)val);
|
2010-08-30 22:51:58 +00:00
|
|
|
}
|
|
|
|
++index;
|
|
|
|
}
|
2010-08-26 20:50:36 +00:00
|
|
|
}
|
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
if (count > index)
|
2010-08-26 20:50:36 +00:00
|
|
|
{
|
2010-08-30 22:51:58 +00:00
|
|
|
// Delete unnecessary items
|
|
|
|
for (int j = index; j < count; ++j)
|
|
|
|
{
|
|
|
|
ListView_DeleteItem(widget, index);
|
|
|
|
}
|
2010-08-26 20:50:36 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
++current;
|
2010-08-26 20:50:36 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2010-08-30 22:51:58 +00:00
|
|
|
|
|
|
|
SendMessage(widget, WM_SETREDRAW, 1, 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
void UpdateWidgets()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
HWND widget;
|
2010-08-26 20:50:36 +00:00
|
|
|
widget = GetDlgItem(g_DialogWin, IDC_ABOUT_ENTRIES);
|
|
|
|
int selected = (int)SendMessage(widget, LB_GETCURSEL, NULL, NULL);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
widget = GetDlgItem(g_DialogWin, IDC_STATISTICS);
|
|
|
|
ListView_DeleteAllItems(widget);
|
|
|
|
|
2010-08-26 20:50:36 +00:00
|
|
|
if (selected == 0)
|
|
|
|
{
|
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_TEXT;
|
|
|
|
lvc.pszText = L"Time";
|
2011-01-31 07:08:43 +00:00
|
|
|
ListView_SetColumn(widget, 0, &lvc);
|
|
|
|
lvc.pszText = L"Type";
|
2010-08-26 20:50:36 +00:00
|
|
|
ListView_SetColumn(widget, 1, &lvc);
|
|
|
|
lvc.pszText = L"Message";
|
|
|
|
ListView_SetColumn(widget, 2, &lvc);
|
|
|
|
}
|
|
|
|
else if (selected == 1)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_TEXT;
|
|
|
|
lvc.pszText = L"Plugin";
|
|
|
|
ListView_SetColumn(widget, 0, &lvc);
|
|
|
|
lvc.pszText = L"Version";
|
|
|
|
ListView_SetColumn(widget, 1, &lvc);
|
|
|
|
lvc.pszText = L"Author";
|
|
|
|
ListView_SetColumn(widget, 2, &lvc);
|
|
|
|
|
|
|
|
// Update the list of plugins
|
2011-01-30 16:21:00 +00:00
|
|
|
if (g_Plugins.empty())
|
|
|
|
{
|
|
|
|
ScanPlugins();
|
|
|
|
}
|
|
|
|
|
2010-03-30 22:37:05 +00:00
|
|
|
std::vector<PLUGIN_INFO>::const_iterator iter = g_Plugins.begin();
|
2009-02-10 18:37:48 +00:00
|
|
|
LVITEM vitem;
|
|
|
|
vitem.mask = LVIF_TEXT;
|
|
|
|
|
|
|
|
int i = 0;
|
2010-03-30 22:37:05 +00:00
|
|
|
for ( ; iter != g_Plugins.end(); ++iter)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (!(*iter).name.empty())
|
|
|
|
{
|
|
|
|
vitem.iItem = i;
|
|
|
|
vitem.iSubItem = 0;
|
|
|
|
vitem.pszText = (WCHAR*)(*iter).name.c_str();
|
|
|
|
ListView_InsertItem(widget, &vitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*iter).version != 0)
|
|
|
|
{
|
2010-09-13 20:06:52 +00:00
|
|
|
WCHAR buffer[64];
|
2010-12-16 20:35:44 +00:00
|
|
|
_snwprintf_s(buffer, _TRUNCATE, L"%u.%u", (*iter).version / 1000, (*iter).version % 1000);
|
2009-02-10 18:37:48 +00:00
|
|
|
ListView_SetItemText(widget, i, 1, buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
ListView_SetItemText(widget, i, 2, (WCHAR*)(*iter).author.c_str());
|
|
|
|
|
2010-03-30 22:37:05 +00:00
|
|
|
++i;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-15 13:22:19 +00:00
|
|
|
if (!g_Plugins.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
ListView_SetItemState(widget, 0, LVIS_SELECTED, LVIS_SELECTED);
|
|
|
|
}
|
|
|
|
}
|
2010-08-30 22:51:58 +00:00
|
|
|
else
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_TEXT;
|
|
|
|
lvc.pszText = L"Measure";
|
|
|
|
ListView_SetColumn(widget, 0, &lvc);
|
|
|
|
lvc.pszText = L"Range";
|
2011-01-31 07:08:43 +00:00
|
|
|
ListView_SetColumn(widget, 1, &lvc);
|
|
|
|
lvc.pszText = L"Value";
|
2009-02-10 18:37:48 +00:00
|
|
|
ListView_SetColumn(widget, 2, &lvc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef LPCTSTR (*GETPLUGINAUTHOR)();
|
|
|
|
typedef UINT (*GETPLUGINVERSION)();
|
|
|
|
|
|
|
|
void ScanPlugins()
|
|
|
|
{
|
2011-01-30 16:21:00 +00:00
|
|
|
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
|
|
|
HANDLE hSearch; // Search handle returned by FindFirstFile
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-07-24 07:56:37 +00:00
|
|
|
std::wstring files = Rainmeter->GetPluginPath() + L"*.dll";
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-01-30 16:21:00 +00:00
|
|
|
// Start searching for .ini files in the given directory.
|
|
|
|
hSearch = FindFirstFile(files.c_str(), &fileData);
|
2009-02-10 18:37:48 +00:00
|
|
|
do
|
|
|
|
{
|
2011-02-03 15:52:45 +00:00
|
|
|
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
PLUGIN_INFO info;
|
|
|
|
info.name = fileData.cFileName;
|
|
|
|
info.version = 0;
|
|
|
|
|
|
|
|
// Try to get the version and author
|
2009-07-24 07:56:37 +00:00
|
|
|
std::wstring tmpSz = Rainmeter->GetPluginPath() + fileData.cFileName;
|
2010-09-11 19:39:45 +00:00
|
|
|
DWORD err = 0;
|
|
|
|
HMODULE dll = CSystem::RmLoadLibrary(tmpSz.c_str(), &err, true);
|
2009-02-10 18:37:48 +00:00
|
|
|
if (dll)
|
|
|
|
{
|
|
|
|
GETPLUGINAUTHOR GetAuthorFunc = (GETPLUGINAUTHOR)GetProcAddress(dll, "GetPluginAuthor");
|
|
|
|
if (GetAuthorFunc)
|
|
|
|
{
|
|
|
|
LPCTSTR author = GetAuthorFunc();
|
2010-11-25 15:34:49 +00:00
|
|
|
if (author && *author)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
info.author = author;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion");
|
|
|
|
if (GetVersionFunc)
|
|
|
|
{
|
|
|
|
info.version = GetVersionFunc();
|
|
|
|
}
|
|
|
|
FreeLibrary(dll);
|
|
|
|
}
|
2010-02-04 07:16:22 +00:00
|
|
|
else
|
|
|
|
{
|
2011-02-03 15:52:45 +00:00
|
|
|
LogWithArgs(LOG_WARNING, L"Unable to load plugin: \"%s\", ErrorCode=%u", tmpSz.c_str(), err);
|
2010-02-04 07:16:22 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
g_Plugins.push_back(info);
|
|
|
|
}
|
2011-02-03 15:52:45 +00:00
|
|
|
while (FindNextFile(hSearch, &fileData));
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-02-03 15:52:45 +00:00
|
|
|
FindClose(hSearch);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RepositionControls(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
RECT r, br, ar, sr, wr;
|
|
|
|
HWND widget;
|
|
|
|
|
|
|
|
GetClientRect(hwndDlg, &r);
|
|
|
|
GetClientRect(GetDlgItem(hwndDlg, IDOK), &br);
|
|
|
|
GetClientRect(GetDlgItem(hwndDlg, IDC_STATIC_ABOUT), &ar);
|
|
|
|
GetClientRect(GetDlgItem(hwndDlg, IDC_VERSION_STRING), &sr);
|
|
|
|
|
|
|
|
// Reposition the statistics widgets
|
|
|
|
widget = GetDlgItem(hwndDlg, IDC_STATIC_ABOUT);
|
|
|
|
SetWindowPos(widget, NULL, 0, 0, r.right - 22, ar.bottom, SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
widget = GetDlgItem(hwndDlg, IDC_VERSION_STRING);
|
|
|
|
SetWindowPos(widget, NULL, 0, 0, r.right - 44, sr.bottom, SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
widget = GetDlgItem(hwndDlg, IDC_BUILD_STRING);
|
|
|
|
SetWindowPos(widget, NULL, 0, 0, r.right - 44, sr.bottom, SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
widget = GetDlgItem(hwndDlg, IDC_URL_STRING);
|
|
|
|
SetWindowPos(widget, NULL, 0, 0, r.right - 44, sr.bottom, SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
|
2010-06-21 16:00:19 +00:00
|
|
|
widget = GetDlgItem(hwndDlg, IDC_DISABLE_VERSION_CHECK);
|
2009-02-10 18:37:48 +00:00
|
|
|
GetClientRect(widget, &wr);
|
|
|
|
MapWindowPoints(widget, hwndDlg, (LPPOINT)&wr, 2);
|
2010-08-05 16:38:28 +00:00
|
|
|
SetWindowPos(widget, NULL, ((r.right - (wr.right - wr.left)) / 2) + 9, wr.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-08-26 20:50:36 +00:00
|
|
|
widget = GetDlgItem(hwndDlg, IDC_ABOUT_ENTRIES);
|
2011-02-01 18:16:34 +00:00
|
|
|
SetWindowPos(widget, NULL, 0, 0, (r.right < 800) ? ((r.right - 28) / 3) : 257, r.bottom - 170, SWP_NOMOVE | SWP_NOZORDER);
|
2009-02-10 18:37:48 +00:00
|
|
|
widget = GetDlgItem(hwndDlg, IDOK);
|
2010-08-26 20:50:36 +00:00
|
|
|
SetWindowPos(widget, NULL, (r.right - br.right) / 2, r.bottom - br.bottom - 9, br.right, br.bottom, SWP_NOZORDER);
|
2011-01-31 07:08:43 +00:00
|
|
|
|
|
|
|
// Set listbox width and adjust third column
|
|
|
|
widget = GetDlgItem(hwndDlg, IDC_STATISTICS);
|
2011-02-01 18:16:34 +00:00
|
|
|
SetWindowPos(widget, NULL, (r.right < 800) ? (18 + ((r.right - 28) / 3)) : 275, 130, (r.right < 800) ? (2 * ((r.right - 28) / 3)) : (r.right - 287), r.bottom - 170, SWP_NOZORDER);
|
2011-01-31 07:08:43 +00:00
|
|
|
|
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_WIDTH;
|
2011-02-01 18:16:34 +00:00
|
|
|
lvc.cx = ((r.right < 800) ? (2 * ((r.right - 28) / 3)) : (r.right - 287)) - 200;
|
2011-01-31 07:08:43 +00:00
|
|
|
ListView_SetColumn(widget, 2, &lvc);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL OnInitAboutDialog(HWND window)
|
|
|
|
{
|
|
|
|
WCHAR tmpSz[256];
|
|
|
|
HWND widget;
|
|
|
|
|
|
|
|
widget = GetDlgItem(window, IDC_VERSION_STRING);
|
2011-02-03 15:52:45 +00:00
|
|
|
_snwprintf_s(tmpSz, _TRUNCATE, L"%s %s%s rev %i %s", APPNAME, APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS);
|
2009-02-10 18:37:48 +00:00
|
|
|
SetWindowText(widget, tmpSz);
|
|
|
|
|
|
|
|
widget = GetDlgItem(window, IDC_BUILD_STRING);
|
2010-12-16 20:35:44 +00:00
|
|
|
_snwprintf_s(tmpSz, _TRUNCATE, L"Built on %s", ConvertToWide(__DATE__).c_str());
|
2009-02-10 18:37:48 +00:00
|
|
|
SetWindowText(widget, tmpSz);
|
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
CheckDlgButton(window, IDC_DISABLE_VERSION_CHECK, Rainmeter->GetDisableVersionCheck() ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
|
2010-08-26 20:50:36 +00:00
|
|
|
// Add entries for each config
|
|
|
|
widget = GetDlgItem(window, IDC_ABOUT_ENTRIES);
|
2011-01-24 10:15:05 +00:00
|
|
|
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
2010-03-30 22:37:05 +00:00
|
|
|
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
2011-02-03 15:52:45 +00:00
|
|
|
for ( ; iter != windows.end(); ++iter)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
CMeterWindow* meterWindow = (*iter).second;
|
2010-08-30 22:51:58 +00:00
|
|
|
const std::wstring& skinName = meterWindow->GetSkinName();
|
|
|
|
SendMessage(widget, LB_ADDSTRING, NULL, (LPARAM)skinName.c_str());
|
|
|
|
size_t namelength = skinName.length();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
int currwidth = (int)SendMessage(widget, LB_GETHORIZONTALEXTENT, NULL, NULL);
|
|
|
|
if(6 * (int)namelength > currwidth)
|
2010-08-26 20:50:36 +00:00
|
|
|
{
|
|
|
|
SendMessage(widget, LB_SETHORIZONTALEXTENT, 6 * namelength, NULL);
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2010-08-26 20:50:36 +00:00
|
|
|
SendMessage(widget, LB_INSERTSTRING, 0, (LPARAM) L"Log");
|
|
|
|
SendMessage(widget, LB_INSERTSTRING, 1, (LPARAM) L"Plugins");
|
|
|
|
SendMessage(widget, LB_INSERTSTRING, 2, (LPARAM) L"--------------------");
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-11-27 10:57:59 +00:00
|
|
|
// Select Log entry
|
|
|
|
SendMessage(widget, LB_SETCURSEL, 0, 0);
|
|
|
|
SetTimer(window, LOGTIMER, 1000, NULL);
|
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
if (g_DialogWin == NULL)
|
|
|
|
{
|
|
|
|
// Add columns to the list view
|
|
|
|
widget = GetDlgItem(window, IDC_STATISTICS);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
//ListView_SetExtendedListViewStyleEx(widget, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
|
|
|
|
ListView_SetExtendedListViewStyleEx(widget, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
|
|
|
|
lvc.iSubItem = 0;
|
2011-01-31 07:08:43 +00:00
|
|
|
lvc.pszText = L"Time";
|
2010-08-30 22:51:58 +00:00
|
|
|
lvc.cx = 110;
|
|
|
|
lvc.fmt = LVCFMT_LEFT; // left-aligned column
|
|
|
|
ListView_InsertColumn(widget, 0, &lvc);
|
|
|
|
lvc.iSubItem = 1;
|
2011-02-01 18:16:34 +00:00
|
|
|
lvc.cx = 85;
|
2011-01-31 07:08:43 +00:00
|
|
|
lvc.pszText = L"Type";
|
2010-08-30 22:51:58 +00:00
|
|
|
ListView_InsertColumn(widget, 1, &lvc);
|
|
|
|
lvc.iSubItem = 2;
|
2011-02-01 18:16:34 +00:00
|
|
|
lvc.cx = 170;
|
2010-11-27 10:57:59 +00:00
|
|
|
lvc.pszText = L"Message";
|
2010-08-30 22:51:58 +00:00
|
|
|
ListView_InsertColumn(widget, 2, &lvc);
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-08-30 22:51:58 +00:00
|
|
|
UpdateWidgets();
|
|
|
|
RepositionControls(window);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2011-01-31 07:08:43 +00:00
|
|
|
switch (message)
|
2011-01-30 16:21:00 +00:00
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
return OnInitAboutDialog(hwndDlg);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-01-30 16:21:00 +00:00
|
|
|
case WM_WINDOWPOSCHANGING:
|
|
|
|
{
|
|
|
|
WINDOWPOS* pos = (WINDOWPOS*)lParam;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-02-03 15:52:45 +00:00
|
|
|
pos->cx = max(420, pos->cx);
|
|
|
|
pos->cy = max(340, pos->cy);
|
2011-01-30 16:21:00 +00:00
|
|
|
}
|
2011-02-05 07:48:29 +00:00
|
|
|
return TRUE;
|
2011-01-30 16:21:00 +00:00
|
|
|
|
|
|
|
case WM_SIZE:
|
|
|
|
RepositionControls(hwndDlg);
|
2011-02-05 07:48:29 +00:00
|
|
|
return TRUE;
|
2011-01-30 16:21:00 +00:00
|
|
|
|
|
|
|
case WM_CLOSE:
|
2011-02-05 07:48:29 +00:00
|
|
|
PostMessage(hwndDlg, WM_DELAYED_CLOSE, 0, 0);
|
2011-01-30 16:21:00 +00:00
|
|
|
return TRUE;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-01-30 16:21:00 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDC_DISABLE_VERSION_CHECK:
|
|
|
|
if (IsDlgButtonChecked(hwndDlg, IDC_DISABLE_VERSION_CHECK))
|
|
|
|
{
|
|
|
|
Rainmeter->SetDisableVersionCheck(TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Rainmeter->SetDisableVersionCheck(FALSE);
|
|
|
|
}
|
2011-02-05 07:48:29 +00:00
|
|
|
return TRUE;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-01-30 16:21:00 +00:00
|
|
|
case IDOK:
|
2011-02-05 07:48:29 +00:00
|
|
|
PostMessage(hwndDlg, WM_DELAYED_CLOSE, 0, 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2011-01-30 16:21:00 +00:00
|
|
|
case IDC_ABOUT_ENTRIES:
|
|
|
|
if (HIWORD(wParam) == LBN_SELCHANGE)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-01-30 16:21:00 +00:00
|
|
|
KillTimer(hwndDlg, LOGTIMER);
|
2010-08-26 20:50:36 +00:00
|
|
|
|
2011-01-30 16:21:00 +00:00
|
|
|
HWND widget = GetDlgItem(hwndDlg, IDC_ABOUT_ENTRIES);
|
|
|
|
if (widget != NULL)
|
2010-08-26 20:50:36 +00:00
|
|
|
{
|
2011-01-30 16:21:00 +00:00
|
|
|
if (0 == (int)SendMessage(widget, LB_GETCURSEL, 0, 0))
|
2010-08-30 22:51:58 +00:00
|
|
|
{
|
2011-01-30 16:21:00 +00:00
|
|
|
SetTimer(g_DialogWin, LOGTIMER, 1000, NULL);
|
2010-08-30 22:51:58 +00:00
|
|
|
}
|
2011-01-30 16:21:00 +00:00
|
|
|
}
|
2010-08-30 22:51:58 +00:00
|
|
|
|
2011-01-30 16:21:00 +00:00
|
|
|
UpdateWidgets();
|
2010-08-30 22:51:58 +00:00
|
|
|
UpdateAboutStatistics();
|
2011-02-05 07:48:29 +00:00
|
|
|
return TRUE;
|
2011-01-30 16:21:00 +00:00
|
|
|
}
|
2010-08-30 22:51:58 +00:00
|
|
|
break;
|
2011-01-30 16:21:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-02-05 07:48:29 +00:00
|
|
|
case WM_DELAYED_CLOSE:
|
|
|
|
KillTimer(hwndDlg, LOGTIMER);
|
|
|
|
Rainmeter->SaveSettings();
|
|
|
|
GetWindowPlacement(hwndDlg, &g_DialogPlacement);
|
|
|
|
if (g_DialogPlacement.showCmd == SW_SHOWMINIMIZED)
|
|
|
|
{
|
|
|
|
g_DialogPlacement.showCmd = SW_SHOWNORMAL;
|
|
|
|
}
|
|
|
|
DestroyWindow(hwndDlg);
|
|
|
|
g_DialogWin = NULL;
|
|
|
|
g_Plugins.clear();
|
|
|
|
return TRUE;
|
|
|
|
|
2011-01-30 16:21:00 +00:00
|
|
|
case WM_TIMER:
|
|
|
|
if (wParam == LOGTIMER)
|
|
|
|
{
|
|
|
|
UpdateAboutStatistics();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2011-01-30 16:21:00 +00:00
|
|
|
return FALSE;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|