INT_PTR CDialogAbout::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case IDC_ABOUTSKINS_ITEMS_LISTBOX: if (HIWORD(wParam) == LBN_SELCHANGE) { UpdateMeasureList(NULL); } break; case IDM_COPY: { HWND item = GetFocus(); if (item == GetDlgItem(m_Window, IDC_ABOUTSKINS_ITEMS_LISTVIEW)) { int sel = ListView_GetNextItem(item, -1, LVNI_FOCUSED | LVNI_SELECTED); if (sel != -1) { std::wstring tmpSz(512, L'0'); ListView_GetItemText(item, sel, 2, &tmpSz[0], 512); CSystem::SetClipboardText(tmpSz); } } } break; default: return 1; } return 0; }
/* ** Updates the list of skins. ** */ void CDialogAbout::CTabSkins::UpdateSkinList() { // Delete all entries HWND item = GetDlgItem(m_Window, IDC_ABOUTSKINS_ITEMS_LISTBOX); ListBox_ResetContent(item); // Add entries for each skin std::wstring::size_type maxLength = 0; const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows(); std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin(); bool found = false; for ( ; iter != windows.end(); ++iter) { const std::wstring& skinName = (*iter).first; std::wstring::size_type curLength = skinName.length(); if (curLength > maxLength) { maxLength = curLength; } const WCHAR* name = skinName.c_str(); int index = ListBox_AddString(item, name); if (!found && m_SkinWindow == (*iter).second) { found = true; m_SkinWindow = (*iter).second; ListBox_SetCurSel(item, index); } } ListBox_SetHorizontalExtent(item, 6 * maxLength); if (!found) { if (windows.empty()) { m_SkinWindow = NULL; item = GetDlgItem(m_Window, IDC_ABOUTSKINS_ITEMS_LISTVIEW); ListView_DeleteAllItems(item); } else { // Default to first skin m_SkinWindow = (*windows.begin()).second; ListBox_SetCurSel(item, 0); UpdateMeasureList(m_SkinWindow); } } }
/* ** Updates the list of skins. ** */ void DialogAbout::TabSkins::UpdateSkinList() { // Delete all entries HWND item = GetControl(Id_SkinsListBox); ListBox_ResetContent(item); // Add entries for each skin std::wstring::size_type maxLength = 0; const std::map<std::wstring, Skin*>& windows = GetRainmeter().GetAllSkins(); std::map<std::wstring, Skin*>::const_iterator iter = windows.begin(); bool found = false; for ( ; iter != windows.end(); ++iter) { const std::wstring& skinName = (*iter).first; std::wstring::size_type curLength = skinName.length(); if (curLength > maxLength) { maxLength = curLength; } const WCHAR* name = skinName.c_str(); int index = ListBox_AddString(item, name); if (!found && m_SkinWindow == (*iter).second) { found = true; m_SkinWindow = (*iter).second; ListBox_SetCurSel(item, index); } } ListBox_SetHorizontalExtent(item, 6 * maxLength); if (!found) { if (windows.empty()) { m_SkinWindow = nullptr; item = GetControl(Id_ItemsListView); ListView_DeleteAllItems(item); } else { // Default to first skin m_SkinWindow = (*windows.begin()).second; ListBox_SetCurSel(item, 0); UpdateMeasureList(m_SkinWindow); } } }
INT_PTR DialogAbout::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case Id_SkinsListBox: if (HIWORD(wParam) == LBN_SELCHANGE) { UpdateMeasureList(nullptr); } break; default: return 1; } return 0; }