Cosmetics

This commit is contained in:
Birunthan Mohanathas 2012-12-13 12:11:27 +02:00
parent 3d6132811f
commit fdd350ef42
3 changed files with 147 additions and 144 deletions

View File

@ -25,6 +25,9 @@
// Shared base class for CDialog and CTab. // Shared base class for CDialog and CTab.
class CBaseDialog class CBaseDialog
{ {
public:
HWND GetControl(WORD id) { return GetDlgItem(m_Window, id); }
protected: protected:
CBaseDialog(); CBaseDialog();
virtual ~CBaseDialog() {} virtual ~CBaseDialog() {}

View File

@ -69,7 +69,7 @@ void CDialogAbout::Open(int tab)
NMHDR nm; NMHDR nm;
nm.code = TCN_SELCHANGE; nm.code = TCN_SELCHANGE;
nm.idFrom = Id_Tab; nm.idFrom = Id_Tab;
nm.hwndFrom = GetDlgItem(c_Dialog->m_Window, Id_Tab); nm.hwndFrom = c_Dialog->GetControl(Id_Tab);
TabCtrl_SetCurSel(nm.hwndFrom, tab); TabCtrl_SetCurSel(nm.hwndFrom, tab);
c_Dialog->OnNotify(0, (LPARAM)&nm); c_Dialog->OnNotify(0, (LPARAM)&nm);
} }
@ -140,7 +140,7 @@ void CDialogAbout::UpdateMeasures(CMeterWindow* meterWindow)
CDialog::CTab& CDialogAbout::GetActiveTab() CDialog::CTab& CDialogAbout::GetActiveTab()
{ {
int sel = TabCtrl_GetCurSel(GetDlgItem(m_Window, Id_Tab)); int sel = TabCtrl_GetCurSel(GetControl(Id_Tab));
if (sel == 0) if (sel == 0)
{ {
return m_TabLog; return m_TabLog;
@ -191,10 +191,10 @@ INT_PTR CDialogAbout::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
int h = HIWORD(lParam); int h = HIWORD(lParam);
RECT r; RECT r;
HWND item = GetDlgItem(m_Window, Id_Tab); HWND item = GetControl(Id_Tab);
SetWindowPos(item, NULL, 0, 0, w - 18, h - 47, SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(item, NULL, 0, 0, w - 18, h - 47, SWP_NOMOVE | SWP_NOZORDER);
item = GetDlgItem(m_Window, Id_CloseButton); item = GetControl(Id_CloseButton);
GetClientRect(item, &r); GetClientRect(item, &r);
SetWindowPos(item, NULL, w - r.right - 9, h - r.bottom - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); SetWindowPos(item, NULL, w - r.right - 9, h - r.bottom - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
@ -239,7 +239,7 @@ INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
CreateControls(s_Controls, _countof(s_Controls), m_Font, GetString); CreateControls(s_Controls, _countof(s_Controls), m_Font, GetString);
HWND item = GetDlgItem(m_Window, Id_Tab); HWND item = GetControl(Id_Tab);
m_TabLog.Create(item); m_TabLog.Create(item);
m_TabSkins.Create(item); m_TabSkins.Create(item);
m_TabPlugins.Create(item); m_TabPlugins.Create(item);
@ -259,14 +259,14 @@ INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
HICON hIcon = GetIcon(IDI_RAINMETER); HICON hIcon = GetIcon(IDI_RAINMETER);
SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
item = GetDlgItem(m_Window, Id_CloseButton); item = GetControl(Id_CloseButton);
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE); SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA) if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
{ {
item = GetDlgItem(m_TabLog.GetWindow(), CTabLog::Id_ItemsListView); item = m_TabLog.GetControl(CTabLog::Id_ItemsListView);
SetWindowTheme(item, L"explorer", NULL); SetWindowTheme(item, L"explorer", NULL);
item = GetDlgItem(m_TabSkins.GetWindow(), CTabSkins::Id_ItemsListView); item = m_TabSkins.GetControl(CTabSkins::Id_ItemsListView);
SetWindowTheme(item, L"explorer", NULL); SetWindowTheme(item, L"explorer", NULL);
} }
@ -371,7 +371,7 @@ void CDialogAbout::CTabLog::Create(HWND owner)
void CDialogAbout::CTabLog::Initialize() void CDialogAbout::CTabLog::Initialize()
{ {
// Add columns to the list view // Add columns to the list view
HWND item = GetDlgItem(m_Window, Id_ItemsListView); HWND item = GetControl(Id_ItemsListView);
ListView_SetExtendedListViewStyleEx(item, 0, LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER); ListView_SetExtendedListViewStyleEx(item, 0, LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
// Set folder/.ini icons for tree list // Set folder/.ini icons for tree list
@ -415,16 +415,16 @@ void CDialogAbout::CTabLog::Initialize()
AddItem((*iter).level, (*iter).timestamp.c_str(), (*iter).message.c_str()); AddItem((*iter).level, (*iter).timestamp.c_str(), (*iter).message.c_str());
} }
item = GetDlgItem(m_Window, Id_ErrorCheckBox); item = GetControl(Id_ErrorCheckBox);
Button_SetCheck(item, BST_CHECKED); Button_SetCheck(item, BST_CHECKED);
item = GetDlgItem(m_Window, Id_WarningCheckBox); item = GetControl(Id_WarningCheckBox);
Button_SetCheck(item, BST_CHECKED); Button_SetCheck(item, BST_CHECKED);
item = GetDlgItem(m_Window, Id_NoticeCheckBox); item = GetControl(Id_NoticeCheckBox);
Button_SetCheck(item, BST_CHECKED); Button_SetCheck(item, BST_CHECKED);
item = GetDlgItem(m_Window, Id_DebugCheckBox); item = GetControl(Id_DebugCheckBox);
Button_SetCheck(item, BST_CHECKED); Button_SetCheck(item, BST_CHECKED);
m_Initialized = true; m_Initialized = true;
@ -439,21 +439,21 @@ void CDialogAbout::CTabLog::Resize(int w, int h)
SetWindowPos(m_Window, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(m_Window, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
RECT r; RECT r;
HWND item = GetDlgItem(m_Window, Id_ErrorCheckBox); HWND item = GetControl(Id_ErrorCheckBox);
GetClientRect(item, &r); GetClientRect(item, &r);
SetWindowPos(item, NULL, 0, h - r.bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER); SetWindowPos(item, NULL, 0, h - r.bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
item = GetDlgItem(m_Window, Id_WarningCheckBox); item = GetControl(Id_WarningCheckBox);
SetWindowPos(item, NULL, r.right, h - r.bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER); SetWindowPos(item, NULL, r.right, h - r.bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
item = GetDlgItem(m_Window, Id_NoticeCheckBox); item = GetControl(Id_NoticeCheckBox);
SetWindowPos(item, NULL, r.right * 2, h - r.bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER); SetWindowPos(item, NULL, r.right * 2, h - r.bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
item = GetDlgItem(m_Window, Id_DebugCheckBox); item = GetControl(Id_DebugCheckBox);
SetWindowPos(item, NULL, r.right * 3, h - r.bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER); SetWindowPos(item, NULL, r.right * 3, h - r.bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
item = GetDlgItem(m_Window, Id_ItemsListView); item = GetControl(Id_ItemsListView);
SetWindowPos(item, NULL, 0, 0, w, h - r.bottom - 7, SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(item, NULL, 0, 0, w, h - r.bottom - 7, SWP_NOMOVE | SWP_NOZORDER);
// Adjust third colum // Adjust third colum
@ -481,31 +481,31 @@ void CDialogAbout::CTabLog::AddItem(int level, LPCWSTR time, LPCWSTR message)
{ {
case LOG_ERROR: case LOG_ERROR:
if (!m_Error) return; if (!m_Error) return;
item = GetDlgItem(m_Window, Id_ErrorCheckBox); item = GetControl(Id_ErrorCheckBox);
vitem.iImage = 0; vitem.iImage = 0;
break; break;
case LOG_WARNING: case LOG_WARNING:
if (!m_Warning) return; if (!m_Warning) return;
item = GetDlgItem(m_Window, Id_WarningCheckBox); item = GetControl(Id_WarningCheckBox);
vitem.iImage = 1; vitem.iImage = 1;
break; break;
case LOG_NOTICE: case LOG_NOTICE:
if (!m_Notice) return; if (!m_Notice) return;
item = GetDlgItem(m_Window, Id_NoticeCheckBox); item = GetControl(Id_NoticeCheckBox);
vitem.iImage = 2; vitem.iImage = 2;
break; break;
case LOG_DEBUG: case LOG_DEBUG:
if (!m_Debug) return; if (!m_Debug) return;
item = GetDlgItem(m_Window, Id_DebugCheckBox); item = GetControl(Id_DebugCheckBox);
vitem.iImage = I_IMAGENONE; vitem.iImage = I_IMAGENONE;
break; break;
} }
GetWindowText(item, buffer, 32); GetWindowText(item, buffer, 32);
item = GetDlgItem(m_Window, Id_ItemsListView); item = GetControl(Id_ItemsListView);
ListView_InsertItem(item, &vitem); ListView_InsertItem(item, &vitem);
ListView_SetItemText(item, vitem.iItem, 1, (WCHAR*)time); ListView_SetItemText(item, vitem.iItem, 1, (WCHAR*)time);
ListView_SetItemText(item, vitem.iItem, 2, (WCHAR*)message); ListView_SetItemText(item, vitem.iItem, 2, (WCHAR*)message);
@ -632,7 +632,7 @@ void CDialogAbout::CTabSkins::Create(HWND owner)
void CDialogAbout::CTabSkins::Initialize() void CDialogAbout::CTabSkins::Initialize()
{ {
// Add columns to the list view // Add columns to the list view
HWND item = GetDlgItem(m_Window, Id_ItemsListView); HWND item = GetControl(Id_ItemsListView);
ListView_SetExtendedListViewStyleEx(item, 0, LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER); ListView_SetExtendedListViewStyleEx(item, 0, LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
LVGROUP lvg; LVGROUP lvg;
@ -677,11 +677,11 @@ void CDialogAbout::CTabSkins::Resize(int w, int h)
{ {
SetWindowPos(m_Window, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(m_Window, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
HWND item = GetDlgItem(m_Window, Id_SkinsListBox); HWND item = GetControl(Id_SkinsListBox);
int wList = (w < 650) ? (w - 373) : 277; int wList = (w < 650) ? (w - 373) : 277;
SetWindowPos(item, NULL, 0, 0, wList, h, SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(item, NULL, 0, 0, wList, h, SWP_NOMOVE | SWP_NOZORDER);
item = GetDlgItem(m_Window, Id_ItemsListView); item = GetControl(Id_ItemsListView);
SetWindowPos(item, NULL, (w < 650) ? (w - 365) : 285, 0, w - wList - 10, h, SWP_NOZORDER); SetWindowPos(item, NULL, (w < 650) ? (w - 365) : 285, 0, w - wList - 10, h, SWP_NOZORDER);
// Adjust third column // Adjust third column
@ -698,7 +698,7 @@ void CDialogAbout::CTabSkins::Resize(int w, int h)
void CDialogAbout::CTabSkins::UpdateSkinList() void CDialogAbout::CTabSkins::UpdateSkinList()
{ {
// Delete all entries // Delete all entries
HWND item = GetDlgItem(m_Window, Id_SkinsListBox); HWND item = GetControl(Id_SkinsListBox);
ListBox_ResetContent(item); ListBox_ResetContent(item);
// Add entries for each skin // Add entries for each skin
@ -732,7 +732,7 @@ void CDialogAbout::CTabSkins::UpdateSkinList()
if (windows.empty()) if (windows.empty())
{ {
m_SkinWindow = NULL; m_SkinWindow = NULL;
item = GetDlgItem(m_Window, Id_ItemsListView); item = GetControl(Id_ItemsListView);
ListView_DeleteAllItems(item); ListView_DeleteAllItems(item);
} }
else else
@ -754,7 +754,7 @@ void CDialogAbout::CTabSkins::UpdateMeasureList(CMeterWindow* meterWindow)
if (!meterWindow) if (!meterWindow)
{ {
// Find selected skin // Find selected skin
HWND item = GetDlgItem(m_Window, Id_SkinsListBox); HWND item = GetControl(Id_SkinsListBox);
int selected = (int)SendMessage(item, LB_GETCURSEL, NULL, NULL); int selected = (int)SendMessage(item, LB_GETCURSEL, NULL, NULL);
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows(); const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
@ -773,7 +773,7 @@ void CDialogAbout::CTabSkins::UpdateMeasureList(CMeterWindow* meterWindow)
return; return;
} }
HWND item = GetDlgItem(m_Window, Id_ItemsListView); HWND item = GetControl(Id_ItemsListView);
SendMessage(item, WM_SETREDRAW, FALSE, 0); SendMessage(item, WM_SETREDRAW, FALSE, 0);
int count = ListView_GetItemCount(item); int count = ListView_GetItemCount(item);
@ -901,7 +901,7 @@ INT_PTR CDialogAbout::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
case IDM_COPY: case IDM_COPY:
{ {
HWND item = GetFocus(); HWND item = GetFocus();
if (item == GetDlgItem(m_Window, Id_ItemsListView)) if (item == GetControl(Id_ItemsListView))
{ {
int sel = ListView_GetNextItem(item, -1, LVNI_FOCUSED | LVNI_SELECTED); int sel = ListView_GetNextItem(item, -1, LVNI_FOCUSED | LVNI_SELECTED);
if (sel != -1) if (sel != -1)
@ -976,7 +976,7 @@ void CDialogAbout::CTabPlugins::Create(HWND owner)
void CDialogAbout::CTabPlugins::Initialize() void CDialogAbout::CTabPlugins::Initialize()
{ {
// Add columns to the list view // Add columns to the list view
HWND item = GetDlgItem(m_Window, Id_ItemsListView); HWND item = GetControl(Id_ItemsListView);
LVCOLUMN lvc; LVCOLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
@ -1123,7 +1123,7 @@ void CDialogAbout::CTabPlugins::Resize(int w, int h)
{ {
SetWindowPos(m_Window, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(m_Window, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
HWND item = GetDlgItem(m_Window, Id_ItemsListView); HWND item = GetControl(Id_ItemsListView);
SetWindowPos(item, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(item, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
// Adjust third colum // Adjust third colum
@ -1187,24 +1187,24 @@ void CDialogAbout::CTabVersion::Create(HWND owner)
void CDialogAbout::CTabVersion::Initialize() void CDialogAbout::CTabVersion::Initialize()
{ {
HWND item = GetDlgItem(m_Window, Id_AppIcon); HWND item = GetControl(Id_AppIcon);
HICON icon = GetIcon(IDI_RAINMETER, true); HICON icon = GetIcon(IDI_RAINMETER, true);
Static_SetIcon(item, icon); Static_SetIcon(item, icon);
item = GetDlgItem(m_Window, Id_VersionLabel); item = GetControl(Id_VersionLabel);
WCHAR tmpSz[64]; WCHAR tmpSz[64];
_snwprintf_s(tmpSz, _TRUNCATE, L"%s%s r%i %s (%s)", APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE); _snwprintf_s(tmpSz, _TRUNCATE, L"%s%s r%i %s (%s)", APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE);
SetWindowText(item, tmpSz); SetWindowText(item, tmpSz);
item = GetDlgItem(m_Window, Id_PathLabel); item = GetControl(Id_PathLabel);
std::wstring text = L"Path: " + Rainmeter->GetPath(); std::wstring text = L"Path: " + Rainmeter->GetPath();
SetWindowText(item, text.c_str()); SetWindowText(item, text.c_str());
item = GetDlgItem(m_Window, Id_IniFileLabel); item = GetControl(Id_IniFileLabel);
text = L"IniFile: " + Rainmeter->GetIniFile(); text = L"IniFile: " + Rainmeter->GetIniFile();
SetWindowText(item, text.c_str()); SetWindowText(item, text.c_str());
item = GetDlgItem(m_Window, Id_SkinPathLabel); item = GetControl(Id_SkinPathLabel);
text = L"SkinPath: " + Rainmeter->GetSkinPath(); text = L"SkinPath: " + Rainmeter->GetSkinPath();
SetWindowText(item, text.c_str()); SetWindowText(item, text.c_str());

View File

@ -96,7 +96,7 @@ void CDialogManage::Open(int tab)
NMHDR nm; NMHDR nm;
nm.code = TCN_SELCHANGE; nm.code = TCN_SELCHANGE;
nm.idFrom = Id_Tab; nm.idFrom = Id_Tab;
nm.hwndFrom = GetDlgItem(c_Dialog->m_Window, Id_Tab); nm.hwndFrom = c_Dialog->GetControl(Id_Tab);
TabCtrl_SetCurSel(nm.hwndFrom, tab); TabCtrl_SetCurSel(nm.hwndFrom, tab);
c_Dialog->OnNotify(0, (LPARAM)&nm); c_Dialog->OnNotify(0, (LPARAM)&nm);
} }
@ -114,7 +114,7 @@ void CDialogManage::OpenSkin(CMeterWindow* meterWindow)
std::wstring name = meterWindow->GetFolderPath() + L'\\'; std::wstring name = meterWindow->GetFolderPath() + L'\\';
name += meterWindow->GetFileName(); name += meterWindow->GetFileName();
HWND item = GetDlgItem(c_Dialog->m_TabSkins.GetWindow(), CTabSkins::Id_SkinsTreeView); HWND item = c_Dialog->m_TabSkins.GetControl(CTabSkins::Id_SkinsTreeView);
c_Dialog->m_TabSkins.SelectTreeItem(item, TreeView_GetRoot(item), name.c_str()); c_Dialog->m_TabSkins.SelectTreeItem(item, TreeView_GetRoot(item), name.c_str());
} }
} }
@ -133,7 +133,7 @@ void CDialogManage::UpdateSkins(CMeterWindow* meterWindow, bool deleted)
CDialog::CTab& CDialogManage::GetActiveTab() CDialog::CTab& CDialogManage::GetActiveTab()
{ {
int sel = TabCtrl_GetCurSel(GetDlgItem(m_Window, Id_Tab)); int sel = TabCtrl_GetCurSel(GetControl(Id_Tab));
if (sel == 0) if (sel == 0)
{ {
return m_TabSkins; return m_TabSkins;
@ -188,6 +188,9 @@ INT_PTR CDialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam)
const ControlTemplate::Control s_Controls[] = const ControlTemplate::Control s_Controls[] =
{ {
CT_TAB(Id_Tab, 0,
6, 6, 488, 293,
WS_VISIBLE | WS_TABSTOP | TCS_FIXEDWIDTH, WS_EX_CONTROLPARENT),
CT_BUTTON(Id_RefreshAllButton, ID_STR_REFRESHALL, CT_BUTTON(Id_RefreshAllButton, ID_STR_REFRESHALL,
5, 303, buttonWidth, 14, 5, 303, buttonWidth, 14,
WS_VISIBLE | WS_TABSTOP, 0), WS_VISIBLE | WS_TABSTOP, 0),
@ -202,15 +205,12 @@ INT_PTR CDialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam)
WS_VISIBLE | WS_TABSTOP, 0), WS_VISIBLE | WS_TABSTOP, 0),
CT_BUTTON(Id_CloseButton, ID_STR_CLOSE, CT_BUTTON(Id_CloseButton, ID_STR_CLOSE,
444, 303, 50, 14, 444, 303, 50, 14,
WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 0), WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 0)
CT_TAB(Id_Tab, 0,
6, 6, 488, 293,
WS_VISIBLE | WS_TABSTOP | TCS_FIXEDWIDTH, 0) // Last for correct tab order.
}; };
CreateControls(s_Controls, _countof(s_Controls), m_Font, GetString); CreateControls(s_Controls, _countof(s_Controls), m_Font, GetString);
HWND item = GetDlgItem(m_Window, Id_Tab); HWND item = GetControl(Id_Tab);
m_TabSkins.Create(item); m_TabSkins.Create(item);
m_TabLayouts.Create(item); m_TabLayouts.Create(item);
m_TabSettings.Create(item); m_TabSettings.Create(item);
@ -227,16 +227,16 @@ INT_PTR CDialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam)
HICON hIcon = GetIcon(IDI_RAINMETER); HICON hIcon = GetIcon(IDI_RAINMETER);
SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
item = GetDlgItem(m_Window, Id_CloseButton); item = GetControl(Id_CloseButton);
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE); SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
item = GetDlgItem(m_TabSkins.GetWindow(), CTabSkins::Id_FileLabel); item = m_TabSkins.GetControl(CTabSkins::Id_FileLabel);
SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0); SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0);
if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA) if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
{ {
// Use arrows instead of plus/minus in the tree for Vista+ // Use arrows instead of plus/minus in the tree for Vista+
item = GetDlgItem(m_TabSkins.GetWindow(), CTabSkins::Id_SkinsTreeView); item = m_TabSkins.GetControl(CTabSkins::Id_SkinsTreeView);
SetWindowTheme(item, L"explorer", NULL); SetWindowTheme(item, L"explorer", NULL);
} }
@ -473,10 +473,10 @@ void CDialogManage::CTabSkins::Initialize()
bsi.size.cx = 20; bsi.size.cx = 20;
bsi.size.cy = 14; bsi.size.cy = 14;
HWND item = GetDlgItem(m_Window, Id_ActiveSkinsButton); HWND item = GetControl(Id_ActiveSkinsButton);
CDialog::SetMenuButton(item); CDialog::SetMenuButton(item);
item = GetDlgItem(m_Window, Id_DisplayMonitorButton); item = GetControl(Id_DisplayMonitorButton);
CDialog::SetMenuButton(item); CDialog::SetMenuButton(item);
// Load folder/.ini icons from shell32 // Load folder/.ini icons from shell32
@ -489,16 +489,16 @@ void CDialogManage::CTabSkins::Initialize()
ImageList_AddIcon(hImageList, hIcon); ImageList_AddIcon(hImageList, hIcon);
// Apply icons and populate tree // Apply icons and populate tree
item = GetDlgItem(m_Window, Id_SkinsTreeView); item = GetControl(Id_SkinsTreeView);
TreeView_SetImageList(item, hImageList, TVSIL_NORMAL); TreeView_SetImageList(item, hImageList, TVSIL_NORMAL);
Update(NULL, false); Update(NULL, false);
// Get rid of the EDITTEXT control border // Get rid of the EDITTEXT control border
item = GetDlgItem(m_Window, Id_DescriptionLabel); item = GetControl(Id_DescriptionLabel);
SetWindowLongPtr(item, GWL_EXSTYLE, GetWindowLongPtr(item, GWL_EXSTYLE) &~ WS_EX_CLIENTEDGE); SetWindowLongPtr(item, GWL_EXSTYLE, GetWindowLongPtr(item, GWL_EXSTYLE) &~ WS_EX_CLIENTEDGE);
SetWindowPos(item, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(item, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
item = GetDlgItem(m_Window, Id_TransparencyDropDownList); item = GetControl(Id_TransparencyDropDownList);
ComboBox_AddString(item, L"0%"); ComboBox_AddString(item, L"0%");
ComboBox_AddString(item, L"10%"); ComboBox_AddString(item, L"10%");
ComboBox_AddString(item, L"20%"); ComboBox_AddString(item, L"20%");
@ -510,14 +510,14 @@ void CDialogManage::CTabSkins::Initialize()
ComboBox_AddString(item, L"80%"); ComboBox_AddString(item, L"80%");
ComboBox_AddString(item, L"90%"); ComboBox_AddString(item, L"90%");
item = GetDlgItem(m_Window, Id_ZPositionDropDownList); item = GetControl(Id_ZPositionDropDownList);
ComboBox_AddString(item, GetString(ID_STR_ONDESKTOP)); ComboBox_AddString(item, GetString(ID_STR_ONDESKTOP));
ComboBox_AddString(item, GetString(ID_STR_BOTTOM)); ComboBox_AddString(item, GetString(ID_STR_BOTTOM));
ComboBox_AddString(item, GetString(ID_STR_NORMAL)); ComboBox_AddString(item, GetString(ID_STR_NORMAL));
ComboBox_AddString(item, GetString(ID_STR_TOPMOST)); ComboBox_AddString(item, GetString(ID_STR_TOPMOST));
ComboBox_AddString(item, GetString(ID_STR_STAYTOPMOST)); ComboBox_AddString(item, GetString(ID_STR_STAYTOPMOST));
item = GetDlgItem(m_Window, Id_OnHoverDropDownList); item = GetControl(Id_OnHoverDropDownList);
ComboBox_AddString(item, GetString(ID_STR_DONOTHING)); ComboBox_AddString(item, GetString(ID_STR_DONOTHING));
ComboBox_AddString(item, GetString(ID_STR_HIDE)); ComboBox_AddString(item, GetString(ID_STR_HIDE));
ComboBox_AddString(item, GetString(ID_STR_FADEIN)); ComboBox_AddString(item, GetString(ID_STR_FADEIN));
@ -564,7 +564,7 @@ void CDialogManage::CTabSkins::Update(CMeterWindow* meterWindow, bool deleted)
else else
{ {
// Populate tree // Populate tree
HWND item = GetDlgItem(m_Window, Id_SkinsTreeView); HWND item = GetControl(Id_SkinsTreeView);
TreeView_DeleteAllItems(item); TreeView_DeleteAllItems(item);
TVINSERTSTRUCT tvi = {0}; TVINSERTSTRUCT tvi = {0};
@ -583,33 +583,33 @@ void CDialogManage::CTabSkins::SetControls()
{ {
WCHAR buffer[64]; WCHAR buffer[64];
HWND item = GetDlgItem(m_Window, Id_EditButton); HWND item = GetControl(Id_EditButton);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
item = GetDlgItem(m_Window, Id_LoadButton); item = GetControl(Id_LoadButton);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
if (m_SkinWindow) if (m_SkinWindow)
{ {
SetWindowText(item, GetString(ID_STR_UNLOAD)); SetWindowText(item, GetString(ID_STR_UNLOAD));
item = GetDlgItem(m_Window, Id_RefreshButton); item = GetControl(Id_RefreshButton);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
item = GetDlgItem(m_Window, Id_XPositionEdit); item = GetControl(Id_XPositionEdit);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
_itow_s(m_SkinWindow->GetX(), buffer, 10); _itow_s(m_SkinWindow->GetX(), buffer, 10);
SetWindowText(item, buffer); SetWindowText(item, buffer);
item = GetDlgItem(m_Window, Id_YPositionEdit); item = GetControl(Id_YPositionEdit);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
_itow_s(m_SkinWindow->GetY(), buffer, 10); _itow_s(m_SkinWindow->GetY(), buffer, 10);
SetWindowText(item, buffer); SetWindowText(item, buffer);
item = GetDlgItem(m_Window, Id_DisplayMonitorButton); item = GetControl(Id_DisplayMonitorButton);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
item = GetDlgItem(m_Window, Id_DraggableCheckBox); item = GetControl(Id_DraggableCheckBox);
if (Rainmeter->GetDisableDragging()) if (Rainmeter->GetDisableDragging())
{ {
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
@ -621,39 +621,39 @@ void CDialogManage::CTabSkins::SetControls()
Button_SetCheck(item, m_SkinWindow->GetWindowDraggable()); Button_SetCheck(item, m_SkinWindow->GetWindowDraggable());
} }
item = GetDlgItem(m_Window, Id_ClickThroughCheckBox); item = GetControl(Id_ClickThroughCheckBox);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
Button_SetCheck(item, m_SkinWindow->GetClickThrough()); Button_SetCheck(item, m_SkinWindow->GetClickThrough());
item = GetDlgItem(m_Window, Id_KeepOnScreenCheckBox); item = GetControl(Id_KeepOnScreenCheckBox);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
Button_SetCheck(item, m_SkinWindow->GetKeepOnScreen()); Button_SetCheck(item, m_SkinWindow->GetKeepOnScreen());
item = GetDlgItem(m_Window, Id_SavePositionCheckBox); item = GetControl(Id_SavePositionCheckBox);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
Button_SetCheck(item, m_SkinWindow->GetSavePosition()); Button_SetCheck(item, m_SkinWindow->GetSavePosition());
item = GetDlgItem(m_Window, Id_SnapToEdgesCheckBox); item = GetControl(Id_SnapToEdgesCheckBox);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
Button_SetCheck(item, m_SkinWindow->GetSnapEdges()); Button_SetCheck(item, m_SkinWindow->GetSnapEdges());
item = GetDlgItem(m_Window, Id_TransparencyDropDownList); item = GetControl(Id_TransparencyDropDownList);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
int value = (int)(10 - m_SkinWindow->GetAlphaValue() / 25.5); int value = (int)(10 - m_SkinWindow->GetAlphaValue() / 25.5);
value = min(9, value); value = min(9, value);
value = max(0, value); value = max(0, value);
ComboBox_SetCurSel(item, value); ComboBox_SetCurSel(item, value);
item = GetDlgItem(m_Window, Id_ZPositionDropDownList); item = GetControl(Id_ZPositionDropDownList);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
ComboBox_SetCurSel(item, m_SkinWindow->GetWindowZPosition() + 2); ComboBox_SetCurSel(item, m_SkinWindow->GetWindowZPosition() + 2);
item = GetDlgItem(m_Window, Id_LoadOrderEdit); item = GetControl(Id_LoadOrderEdit);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
_itow_s(Rainmeter->GetLoadOrder(m_SkinFolderPath), buffer, 10); _itow_s(Rainmeter->GetLoadOrder(m_SkinFolderPath), buffer, 10);
SetWindowText(item, buffer); SetWindowText(item, buffer);
item = GetDlgItem(m_Window, Id_OnHoverDropDownList); item = GetControl(Id_OnHoverDropDownList);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
ComboBox_SetCurSel(item, m_SkinWindow->GetWindowHide()); ComboBox_SetCurSel(item, m_SkinWindow->GetWindowHide());
} }
@ -665,36 +665,36 @@ void CDialogManage::CTabSkins::SetControls()
void CDialogManage::CTabSkins::DisableControls(bool clear) void CDialogManage::CTabSkins::DisableControls(bool clear)
{ {
HWND item = GetDlgItem(m_Window, Id_LoadButton); HWND item = GetControl(Id_LoadButton);
SetWindowText(item, GetString(ID_STR_LOAD)); SetWindowText(item, GetString(ID_STR_LOAD));
if (clear) if (clear)
{ {
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
item = GetDlgItem(m_Window, Id_EditButton); item = GetControl(Id_EditButton);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
item = GetDlgItem(m_Window, Id_FileLabel); item = GetControl(Id_FileLabel);
SetWindowText(item, GetString(ID_STR_ELLIPSIS)); SetWindowText(item, GetString(ID_STR_ELLIPSIS));
item = GetDlgItem(m_Window, Id_ConfigLabel); item = GetControl(Id_ConfigLabel);
SetWindowText(item, L""); SetWindowText(item, L"");
item = GetDlgItem(m_Window, Id_AuthorLabel); item = GetControl(Id_AuthorLabel);
SetWindowText(item, L""); SetWindowText(item, L"");
item = GetDlgItem(m_Window, Id_VersionLabel); item = GetControl(Id_VersionLabel);
SetWindowText(item, L""); SetWindowText(item, L"");
item = GetDlgItem(m_Window, Id_LicenseLabel); item = GetControl(Id_LicenseLabel);
SetWindowText(item, L""); SetWindowText(item, L"");
item = GetDlgItem(m_Window, Id_DescriptionLabel); item = GetControl(Id_DescriptionLabel);
SetWindowText(item, L""); SetWindowText(item, L"");
ShowScrollBar(item, SB_VERT, FALSE); ShowScrollBar(item, SB_VERT, FALSE);
item = GetDlgItem(m_Window, Id_AddMetadataLink); item = GetControl(Id_AddMetadataLink);
ShowWindow(item, SW_HIDE); ShowWindow(item, SW_HIDE);
} }
else else
@ -702,65 +702,65 @@ void CDialogManage::CTabSkins::DisableControls(bool clear)
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
} }
item = GetDlgItem(m_Window, Id_RefreshButton); item = GetControl(Id_RefreshButton);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
item = GetDlgItem(m_Window, Id_XPositionEdit); item = GetControl(Id_XPositionEdit);
SetWindowText(item, L""); SetWindowText(item, L"");
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
item = GetDlgItem(m_Window, Id_YPositionEdit); item = GetControl(Id_YPositionEdit);
SetWindowText(item, L""); SetWindowText(item, L"");
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
item = GetDlgItem(m_Window, Id_DisplayMonitorButton); item = GetControl(Id_DisplayMonitorButton);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
item = GetDlgItem(m_Window, Id_DraggableCheckBox); item = GetControl(Id_DraggableCheckBox);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
Button_SetCheck(item, BST_UNCHECKED); Button_SetCheck(item, BST_UNCHECKED);
item = GetDlgItem(m_Window, Id_ClickThroughCheckBox); item = GetControl(Id_ClickThroughCheckBox);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
Button_SetCheck(item, BST_UNCHECKED); Button_SetCheck(item, BST_UNCHECKED);
item = GetDlgItem(m_Window, Id_KeepOnScreenCheckBox); item = GetControl(Id_KeepOnScreenCheckBox);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
Button_SetCheck(item, BST_UNCHECKED); Button_SetCheck(item, BST_UNCHECKED);
item = GetDlgItem(m_Window, Id_SavePositionCheckBox); item = GetControl(Id_SavePositionCheckBox);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
Button_SetCheck(item, BST_UNCHECKED); Button_SetCheck(item, BST_UNCHECKED);
item = GetDlgItem(m_Window, Id_SnapToEdgesCheckBox); item = GetControl(Id_SnapToEdgesCheckBox);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
Button_SetCheck(item, BST_UNCHECKED); Button_SetCheck(item, BST_UNCHECKED);
item = GetDlgItem(m_Window, Id_TransparencyDropDownList); item = GetControl(Id_TransparencyDropDownList);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
ComboBox_SetCurSel(item, -1); ComboBox_SetCurSel(item, -1);
item = GetDlgItem(m_Window, Id_ZPositionDropDownList); item = GetControl(Id_ZPositionDropDownList);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
ComboBox_SetCurSel(item, -1); ComboBox_SetCurSel(item, -1);
item = GetDlgItem(m_Window, Id_LoadOrderEdit); item = GetControl(Id_LoadOrderEdit);
SetWindowText(item, L""); SetWindowText(item, L"");
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
item = GetDlgItem(m_Window, Id_OnHoverDropDownList); item = GetControl(Id_OnHoverDropDownList);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
ComboBox_SetCurSel(item, -1); ComboBox_SetCurSel(item, -1);
} }
void CDialogManage::CTabSkins::ReadSkin() void CDialogManage::CTabSkins::ReadSkin()
{ {
HWND item = GetDlgItem(m_Window, Id_FileLabel); HWND item = GetControl(Id_FileLabel);
SetWindowText(item, m_SkinFileName.c_str()); SetWindowText(item, m_SkinFileName.c_str());
PathSetDlgItemPath(m_Window, Id_ConfigLabel, m_SkinFolderPath.c_str()); PathSetDlgItemPath(m_Window, Id_ConfigLabel, m_SkinFolderPath.c_str());
item = GetDlgItem(m_Window, Id_EditButton); item = GetControl(Id_EditButton);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
std::wstring file = Rainmeter->GetSkinPath() + m_SkinFolderPath; std::wstring file = Rainmeter->GetSkinPath() + m_SkinFolderPath;
@ -777,7 +777,7 @@ void CDialogManage::CTabSkins::ReadSkin()
WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH]; WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH];
const WCHAR* fileSz = file.c_str(); const WCHAR* fileSz = file.c_str();
item = GetDlgItem(m_Window, Id_AuthorLabel); item = GetControl(Id_AuthorLabel);
if (GetPrivateProfileString(L"Metadata", L"Author", NULL, buffer, MAX_LINE_LENGTH, fileSz) == 0) if (GetPrivateProfileString(L"Metadata", L"Author", NULL, buffer, MAX_LINE_LENGTH, fileSz) == 0)
{ {
// For backwards compatibility. // For backwards compatibility.
@ -785,21 +785,21 @@ void CDialogManage::CTabSkins::ReadSkin()
} }
SetWindowText(item, buffer); SetWindowText(item, buffer);
item = GetDlgItem(m_Window, Id_AddMetadataLink); item = GetControl(Id_AddMetadataLink);
if (GetPrivateProfileSection(L"Metadata", buffer, 8, fileSz) > 0) if (GetPrivateProfileSection(L"Metadata", buffer, 8, fileSz) > 0)
{ {
ShowWindow(item, SW_HIDE); ShowWindow(item, SW_HIDE);
// Set metadata // Set metadata
item = GetDlgItem(m_Window, Id_VersionLabel); item = GetControl(Id_VersionLabel);
GetPrivateProfileString(L"Metadata", L"Version", NULL, buffer, MAX_LINE_LENGTH, fileSz); GetPrivateProfileString(L"Metadata", L"Version", NULL, buffer, MAX_LINE_LENGTH, fileSz);
SetWindowText(item, buffer); SetWindowText(item, buffer);
item = GetDlgItem(m_Window, Id_LicenseLabel); item = GetControl(Id_LicenseLabel);
GetPrivateProfileString(L"Metadata", L"License", NULL, buffer, MAX_LINE_LENGTH, fileSz); GetPrivateProfileString(L"Metadata", L"License", NULL, buffer, MAX_LINE_LENGTH, fileSz);
SetWindowText(item, buffer); SetWindowText(item, buffer);
item = GetDlgItem(m_Window, Id_DescriptionLabel); item = GetControl(Id_DescriptionLabel);
std::wstring text; std::wstring text;
if (GetPrivateProfileString(L"Metadata", L"Information", NULL, buffer, MAX_LINE_LENGTH, fileSz) > 0) if (GetPrivateProfileString(L"Metadata", L"Information", NULL, buffer, MAX_LINE_LENGTH, fileSz) > 0)
{ {
@ -840,13 +840,13 @@ void CDialogManage::CTabSkins::ReadSkin()
{ {
ShowWindow(item, SW_SHOWNORMAL); ShowWindow(item, SW_SHOWNORMAL);
item = GetDlgItem(m_Window, Id_VersionLabel); item = GetControl(Id_VersionLabel);
SetWindowText(item, L""); SetWindowText(item, L"");
item = GetDlgItem(m_Window, Id_LicenseLabel); item = GetControl(Id_LicenseLabel);
SetWindowText(item, L""); SetWindowText(item, L"");
item = GetDlgItem(m_Window, Id_DescriptionLabel); item = GetControl(Id_DescriptionLabel);
SetWindowText(item, L""); SetWindowText(item, L"");
ShowScrollBar(item, SB_VERT, FALSE); ShowScrollBar(item, SB_VERT, FALSE);
} }
@ -1059,7 +1059,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
NMHDR nm; NMHDR nm;
nm.code = TVN_SELCHANGED; nm.code = TVN_SELCHANGED;
nm.idFrom = Id_SkinsTreeView; nm.idFrom = Id_SkinsTreeView;
nm.hwndFrom = GetDlgItem(m_Window, Id_SkinsTreeView); nm.hwndFrom = GetControl(Id_SkinsTreeView);
OnNotify(0, (LPARAM)&nm); OnNotify(0, (LPARAM)&nm);
} }
} }
@ -1258,7 +1258,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
case IDM_MANAGESKINSMENU_EXPAND: case IDM_MANAGESKINSMENU_EXPAND:
{ {
HWND tree = GetDlgItem(m_Window, Id_SkinsTreeView); HWND tree = GetControl(Id_SkinsTreeView);
HTREEITEM item = TreeView_GetSelection(tree); HTREEITEM item = TreeView_GetSelection(tree);
TreeView_Expand(tree, item, TVE_TOGGLE); TreeView_Expand(tree, item, TVE_TOGGLE);
} }
@ -1266,7 +1266,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
case IDM_MANAGESKINSMENU_OPENFOLDER: case IDM_MANAGESKINSMENU_OPENFOLDER:
{ {
HWND tree = GetDlgItem(m_Window, Id_SkinsTreeView); HWND tree = GetControl(Id_SkinsTreeView);
Rainmeter->OpenSkinFolder(GetTreeSelectionPath(tree)); Rainmeter->OpenSkinFolder(GetTreeSelectionPath(tree));
} }
break; break;
@ -1284,7 +1284,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
std::wstring name = ((*iter).second)->GetFolderPath() + L'\\'; std::wstring name = ((*iter).second)->GetFolderPath() + L'\\';
name += ((*iter).second)->GetFileName(); name += ((*iter).second)->GetFileName();
HWND item = GetDlgItem(m_Window, Id_SkinsTreeView); HWND item = GetControl(Id_SkinsTreeView);
SelectTreeItem(item, TreeView_GetRoot(item), name.c_str()); SelectTreeItem(item, TreeView_GetRoot(item), name.c_str());
break; break;
} }
@ -1545,7 +1545,7 @@ void CDialogManage::CTabLayouts::Create(HWND owner)
void CDialogManage::CTabLayouts::Initialize() void CDialogManage::CTabLayouts::Initialize()
{ {
HWND item = GetDlgItem(m_Window, Id_List); HWND item = GetControl(Id_List);
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts(); const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
for (int i = 0, isize = layouts.size(); i < isize; ++i) for (int i = 0, isize = layouts.size(); i < isize; ++i)
{ {
@ -1574,11 +1574,11 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
{ {
BOOL state = !(Button_GetCheck((HWND)lParam) == BST_CHECKED); BOOL state = !(Button_GetCheck((HWND)lParam) == BST_CHECKED);
HWND item = GetDlgItem(m_Window, Id_ExcludeUnusedSkinsCheckBox); HWND item = GetControl(Id_ExcludeUnusedSkinsCheckBox);
EnableWindow(item, state); EnableWindow(item, state);
Button_SetCheck(item, BST_UNCHECKED); Button_SetCheck(item, BST_UNCHECKED);
item = GetDlgItem(m_Window, Id_IncludeWallpaperCheckBox); item = GetControl(Id_IncludeWallpaperCheckBox);
EnableWindow(item, state); EnableWindow(item, state);
Button_SetCheck(item, BST_UNCHECKED); Button_SetCheck(item, BST_UNCHECKED);
} }
@ -1592,7 +1592,7 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
// Disable save button if no text or if backup // Disable save button if no text or if backup
BOOL state = (len > 0 && _wcsicmp(buffer, L"@Backup") != 0); BOOL state = (len > 0 && _wcsicmp(buffer, L"@Backup") != 0);
EnableWindow(GetDlgItem(m_Window, Id_SaveButton), state); EnableWindow(GetControl(Id_SaveButton), state);
} }
break; break;
@ -1602,18 +1602,18 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
// Ignore clicks that don't hit items // Ignore clicks that don't hit items
if (ListBox_GetCurSel((HWND)lParam) != LB_ERR) if (ListBox_GetCurSel((HWND)lParam) != LB_ERR)
{ {
HWND item = GetDlgItem(m_Window, Id_LoadButton); HWND item = GetControl(Id_LoadButton);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
item = GetDlgItem(m_Window, Id_DeleteButton); item = GetControl(Id_DeleteButton);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
item = GetDlgItem(m_Window, Id_EditButton); item = GetControl(Id_EditButton);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts(); const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
item = GetDlgItem(m_Window, Id_List); item = GetControl(Id_List);
int sel = ListBox_GetCurSel(item); int sel = ListBox_GetCurSel(item);
item = GetDlgItem(m_Window, Id_NameLabel); item = GetControl(Id_NameLabel);
Edit_SetText(item, layouts[sel].c_str()); Edit_SetText(item, layouts[sel].c_str());
} }
} }
@ -1622,7 +1622,7 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
case Id_SaveButton: case Id_SaveButton:
{ {
WCHAR buffer[MAX_PATH]; WCHAR buffer[MAX_PATH];
HWND item = GetDlgItem(m_Window, Id_NameLabel); HWND item = GetControl(Id_NameLabel);
Edit_GetText(item, buffer, MAX_PATH); Edit_GetText(item, buffer, MAX_PATH);
std::wstring layout = buffer; std::wstring layout = buffer;
@ -1648,7 +1648,7 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
path += L"\\Rainmeter.ini"; path += L"\\Rainmeter.ini";
item = GetDlgItem(m_Window, Id_SaveEmptyThemeCheckBox); item = GetControl(Id_SaveEmptyThemeCheckBox);
if (Button_GetCheck(item) != BST_CHECKED) if (Button_GetCheck(item) != BST_CHECKED)
{ {
if (!CSystem::CopyFiles(Rainmeter->GetIniFile(), path)) if (!CSystem::CopyFiles(Rainmeter->GetIniFile(), path))
@ -1659,7 +1659,7 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
} }
// Exclude unused skins // Exclude unused skins
item = GetDlgItem(m_Window, Id_ExcludeUnusedSkinsCheckBox); item = GetControl(Id_ExcludeUnusedSkinsCheckBox);
if (Button_GetCheck(item) == BST_CHECKED) if (Button_GetCheck(item) == BST_CHECKED)
{ {
CConfigParser parser; CConfigParser parser;
@ -1677,7 +1677,7 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
} }
// Save wallpaper // Save wallpaper
item = GetDlgItem(m_Window, Id_IncludeWallpaperCheckBox); item = GetControl(Id_IncludeWallpaperCheckBox);
if (Button_GetCheck(item) == BST_CHECKED) if (Button_GetCheck(item) == BST_CHECKED)
{ {
// Get current wallpaper // Get current wallpaper
@ -1705,7 +1705,7 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
if (!alreadyExists) if (!alreadyExists)
{ {
item = GetDlgItem(m_Window, Id_List); item = GetControl(Id_List);
ListBox_AddString(item, layout.c_str()); ListBox_AddString(item, layout.c_str());
Rainmeter->ScanForLayouts(); Rainmeter->ScanForLayouts();
@ -1715,7 +1715,7 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
case Id_LoadButton: case Id_LoadButton:
{ {
HWND item = GetDlgItem(m_Window, Id_List); HWND item = GetControl(Id_List);
int sel = ListBox_GetCurSel(item); int sel = ListBox_GetCurSel(item);
Rainmeter->LoadLayout(Rainmeter->m_Layouts[sel]); Rainmeter->LoadLayout(Rainmeter->m_Layouts[sel]);
} }
@ -1723,7 +1723,7 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
case Id_EditButton: case Id_EditButton:
{ {
HWND item = GetDlgItem(m_Window, Id_List); HWND item = GetControl(Id_List);
int sel = ListBox_GetCurSel(item); int sel = ListBox_GetCurSel(item);
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts(); const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
@ -1737,7 +1737,7 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
case Id_DeleteButton: case Id_DeleteButton:
{ {
HWND item = GetDlgItem(m_Window, Id_List); HWND item = GetControl(Id_List);
int sel = ListBox_GetCurSel(item); int sel = ListBox_GetCurSel(item);
std::vector<std::wstring>& layouts = const_cast<std::vector<std::wstring>&>(Rainmeter->GetAllLayouts()); std::vector<std::wstring>& layouts = const_cast<std::vector<std::wstring>&>(Rainmeter->GetAllLayouts());
@ -1766,9 +1766,9 @@ INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
} }
} }
EnableWindow(GetDlgItem(m_Window, Id_LoadButton), FALSE); EnableWindow(GetControl(Id_LoadButton), FALSE);
EnableWindow(GetDlgItem(m_Window, Id_DeleteButton), FALSE); EnableWindow(GetControl(Id_DeleteButton), FALSE);
EnableWindow(GetDlgItem(m_Window, Id_EditButton), FALSE); EnableWindow(GetControl(Id_EditButton), FALSE);
} }
} }
break; break;
@ -1857,7 +1857,7 @@ void CDialogManage::CTabSettings::Create(HWND owner)
void CDialogManage::CTabSettings::Initialize() void CDialogManage::CTabSettings::Initialize()
{ {
// Scan for languages // Scan for languages
HWND item = GetDlgItem(m_Window, Id_LanguageDropDownList); HWND item = GetControl(Id_LanguageDropDownList);
std::wstring files = Rainmeter->GetPath() + L"Languages\\*.dll"; std::wstring files = Rainmeter->GetPath() + L"Languages\\*.dll";
WIN32_FIND_DATA fd; WIN32_FIND_DATA fd;
@ -1896,19 +1896,19 @@ void CDialogManage::CTabSettings::Initialize()
FindClose(hSearch); FindClose(hSearch);
} }
Button_SetCheck(GetDlgItem(m_Window, Id_CheckForUpdatesCheckBox), !Rainmeter->GetDisableVersionCheck()); Button_SetCheck(GetControl(Id_CheckForUpdatesCheckBox), !Rainmeter->GetDisableVersionCheck());
Button_SetCheck(GetDlgItem(m_Window, Id_LockSkinsCheckBox), Rainmeter->GetDisableDragging()); Button_SetCheck(GetControl(Id_LockSkinsCheckBox), Rainmeter->GetDisableDragging());
Button_SetCheck(GetDlgItem(m_Window, Id_LogToFileCheckBox), Rainmeter->GetLogging()); Button_SetCheck(GetControl(Id_LogToFileCheckBox), Rainmeter->GetLogging());
Button_SetCheck(GetDlgItem(m_Window, Id_VerboseLoggingCheckbox), Rainmeter->GetDebug()); Button_SetCheck(GetControl(Id_VerboseLoggingCheckbox), Rainmeter->GetDebug());
BOOL isLogFile = (_waccess(Rainmeter->GetLogFile().c_str(), 0) != -1); BOOL isLogFile = (_waccess(Rainmeter->GetLogFile().c_str(), 0) != -1);
EnableWindow(GetDlgItem(m_Window, Id_ShowLogFileButton), isLogFile); EnableWindow(GetControl(Id_ShowLogFileButton), isLogFile);
EnableWindow(GetDlgItem(m_Window, Id_DeleteLogFileButton), isLogFile); EnableWindow(GetControl(Id_DeleteLogFileButton), isLogFile);
Edit_SetText(GetDlgItem(m_Window, Id_EditorEdit), Rainmeter->GetSkinEditor().c_str()); Edit_SetText(GetControl(Id_EditorEdit), Rainmeter->GetSkinEditor().c_str());
bool iconEnabled = Rainmeter->GetTrayWindow()->IsTrayIconEnabled(); bool iconEnabled = Rainmeter->GetTrayWindow()->IsTrayIconEnabled();
Button_SetCheck(GetDlgItem(m_Window, Id_ShowTrayIconCheckBox), iconEnabled); Button_SetCheck(GetControl(Id_ShowTrayIconCheckBox), iconEnabled);
m_Initialized = true; m_Initialized = true;
} }
@ -1953,7 +1953,7 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
if (CDialogAbout::c_Dialog) if (CDialogAbout::c_Dialog)
{ {
int sel = TabCtrl_GetCurSel(GetDlgItem(CDialogAbout::c_Dialog->GetWindow(), CDialogManage::Id_Tab)); int sel = TabCtrl_GetCurSel(CDialogAbout::c_Dialog->GetControl(CDialogManage::Id_Tab));
SendMessage(CDialogAbout::c_Dialog->GetWindow(), WM_CLOSE, 0, 0); SendMessage(CDialogAbout::c_Dialog->GetWindow(), WM_CLOSE, 0, 0);
if (sel == 0) if (sel == 0)
{ {
@ -1999,9 +1999,9 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
Rainmeter->DeleteLogFile(); Rainmeter->DeleteLogFile();
if (_waccess(Rainmeter->GetLogFile().c_str(), 0) == -1) if (_waccess(Rainmeter->GetLogFile().c_str(), 0) == -1)
{ {
Button_SetCheck(GetDlgItem(m_Window, Id_LogToFileCheckBox), BST_UNCHECKED); Button_SetCheck(GetControl(Id_LogToFileCheckBox), BST_UNCHECKED);
EnableWindow(GetDlgItem(m_Window, Id_ShowLogFileButton), FALSE); EnableWindow(GetControl(Id_ShowLogFileButton), FALSE);
EnableWindow(GetDlgItem(m_Window, Id_DeleteLogFileButton), FALSE); EnableWindow(GetControl(Id_DeleteLogFileButton), FALSE);
} }
break; break;
@ -2015,8 +2015,8 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
Rainmeter->StartLogging(); Rainmeter->StartLogging();
if (_waccess(Rainmeter->GetLogFile().c_str(), 0) != -1) if (_waccess(Rainmeter->GetLogFile().c_str(), 0) != -1)
{ {
EnableWindow(GetDlgItem(m_Window, Id_ShowLogFileButton), TRUE); EnableWindow(GetControl(Id_ShowLogFileButton), TRUE);
EnableWindow(GetDlgItem(m_Window, Id_DeleteLogFileButton), TRUE); EnableWindow(GetControl(Id_DeleteLogFileButton), TRUE);
} }
} }
break; break;
@ -2060,7 +2060,7 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
break; break;
} }
Edit_SetText(GetDlgItem(m_Window, Id_EditorEdit), buffer); Edit_SetText(GetControl(Id_EditorEdit), buffer);
} }
break; break;