BOOL CPpcMainWnd::InsertFile(LPTSTR pszFile, int nIndex) { if (!m_hMap) return FALSE; // 有効性チェック if (!IsValidStream(pszFile)) return FALSE; // リストに挿入 FILEINFO* pInfo = new FILEINFO; MAP_GetId3TagFile(m_hMap, pszFile, &pInfo->tag); _tcscpy(pInfo->szPath, pszFile); m_pListFile->Insert((DWORD)pInfo, nIndex); // リストビューに追加 TCHAR szTitle[MAX_PATH]; GetTitle(m_pListFile->GetCount() - 1, szTitle); LVITEM lvi = {0}; lvi.mask = LVIF_TEXT; lvi.iItem = nIndex; lvi.pszText = szTitle; ListView_InsertItem(m_hwndLV, &lvi); // 開いていない場合は開く OpenFirstFile(); return TRUE; }
// リスト BOOL CPpcMainWnd::AddFile(LPTSTR pszFile, LPTSTR pszTitle) { if (!m_hMap) return FALSE; // 存在チェック if (IsExisting(pszFile)) return FALSE; // 有効性チェック if (!IsValidStream(pszFile)) return FALSE; // リストに追加 FILEINFO* pInfo = new FILEINFO; if (pszTitle) _tcscpy(pInfo->szDisplayName, pszTitle); else MAP_GetId3TagFile(m_hMap, pszFile, &pInfo->tag); _tcscpy(pInfo->szPath, pszFile); m_pListFile->Add((DWORD)pInfo); // リストビューに追加 TCHAR szTitle[MAX_PATH]; GetTitle(m_pListFile->GetCount() - 1, szTitle); LVITEM lvi = {0}; lvi.mask = LVIF_TEXT; lvi.iItem = ListView_GetItemCount(m_hwndLV); lvi.pszText = szTitle; ListView_InsertItem(m_hwndLV, &lvi); // 開いていない場合は開く OpenFirstFile(); return TRUE; }
void CMainWnd::AddFile2(LPTSTR pszPath, LPTSTR pszFile, LPTSTR pszTitle) { if (IsValidStream(pszFile)) { AddFile(pszFile, pszTitle); return; } TCHAR szFile[MAX_PATH]; wsprintf(szFile, _T("%s\\%s"), pszPath, pszFile); AddFile(szFile, pszTitle); }