void DoAtlCustomTraitsList() { // Declare the array, with our data type and traits class CAtlList < MyData, MyTraits > MyList; // Create some variables of our data type MyData add_item, search_item; // Add some elements to the list. add_item.ID = 1; _stprintf_s(add_item.name, _T("Rumpelstiltskin")); _stprintf_s(add_item.address, _T("One Grimm Way")); MyList.AddHead(add_item); add_item.ID = 2; _stprintf_s(add_item.name, _T("Rapunzel")); _stprintf_s(add_item.address, _T("One Grimm Way")); MyList.AddHead(add_item); add_item.ID = 3; _stprintf_s(add_item.name, _T("Cinderella")); _stprintf_s(add_item.address, _T("Two Grimm Way")); MyList.AddHead(add_item); // Create an element which will be used // to search the list for a match. search_item.ID = 2; _stprintf_s(search_item.name, _T("Don't care")); _stprintf_s(search_item.address, _T("Don't care")); // Perform a comparison by searching for a match // between any element in the list, and our // search item. This operation will use the // (overridden) comparison operator and will // find a match when the IDs are the same. POSITION i; i = MyList.Find(search_item); if (i != NULL) _tprintf_s(_T("Item found!\n")); else _tprintf_s(_T("Item not found.\n")); }
void CFavoriteOrganizeDlg::SetupList(bool fSave) { int i = m_tab.GetCurSel(); if (fSave) { CAtlList<CString> sl; for (int j = 0; j < m_list.GetItemCount(); j++) { CAtlList<CString> args; ExplodeEsc(m_sl[i].GetAt((POSITION)m_list.GetItemData(j)), args, _T(';')); args.RemoveHead(); args.AddHead(m_list.GetItemText(j, 0)); sl.AddTail(ImplodeEsc(args, _T(';'))); } m_sl[i].RemoveAll(); m_sl[i].AddTailList(&sl); } else { m_list.DeleteAllItems(); POSITION pos = m_sl[i].GetHeadPosition(), tmp; while (pos) { tmp = pos; CAtlList<CString> sl; ExplodeEsc(m_sl[i].GetNext(pos), sl, _T(';'), 3); int n = m_list.InsertItem(m_list.GetItemCount(), sl.RemoveHead()); m_list.SetItemData(n, (DWORD_PTR)tmp); if (!sl.IsEmpty()) { REFERENCE_TIME rt = 0; if (1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0) { DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt); CString str; str.Format(_T("[%02d:%02d:%02d]"), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds); m_list.SetItemText(n, 1, str); } } } UpdateColumnsSizes(); } }
bool CPlayerPlaylistBar::ParseBDMVPlayList(CString fn) { CHdmvClipInfo ClipInfo; CString strPlaylistFile; CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist; CPath Path(fn); Path.RemoveFileSpec(); Path.RemoveFileSpec(); if (SUCCEEDED(ClipInfo.FindMainMovie(Path + L"\\", strPlaylistFile, MainPlaylist, ((CMainFrame*)GetParentFrame())->m_MPLSPlaylist))) { CAtlList<CString> strFiles; strFiles.AddHead(strPlaylistFile); Append(strFiles, MainPlaylist.GetCount() > 1, NULL); } return m_pl.GetCount() > 0; }
HRESULT XySubRenderProviderWrapper::Render( REFERENCE_TIME now, POSITION pos, double fps ) { if(m_pSubPic && m_pSubPic->GetStart() <= now && now < m_pSubPic->GetStop()) { return S_OK; } HRESULT hr = E_FAIL; //should always re-alloc one for the old be in used by the consumer m_pSubPic = NULL; ASSERT(m_allocator); if(FAILED(m_allocator->AllocDynamicEx(&m_pSubPic))) { XY_LOG_ERROR("Failed to allocate subpic"); return E_FAIL; } ASSERT(m_pSubPic); if(FAILED(m_provider->Lock())) { return hr; } CMemSubPic * mem_subpic = dynamic_cast<CMemSubPic*>((ISubPicEx *)m_pSubPic); ASSERT(mem_subpic); SubPicDesc spd; if(SUCCEEDED(m_pSubPic->Lock(spd))) { CAtlList<CRect> rectList; DWORD color = 0xFF000000; if(SUCCEEDED(m_pSubPic->ClearDirtyRect(color))) { hr = m_provider->RenderEx(spd, now, fps, rectList); if (!m_provider->IsAnimated(pos)) { REFERENCE_TIME start = m_provider->GetStart(pos, fps); REFERENCE_TIME stop = m_provider->GetStop(pos, fps); XY_LOG_TRACE(XY_LOG_VAR_2_STR(start)<<XY_LOG_VAR_2_STR(stop)); m_pSubPic->SetStart(start); m_pSubPic->SetStop(stop); } else { m_pSubPic->SetStart(now); m_pSubPic->SetStop(now+1); } } else { rectList.AddHead(CRect(CPoint(0,0),m_original_video_size)); XY_LOG_ERROR("Failed to clear subpic!"); } hr = m_pSubPic->UnlockEx(&rectList); ASSERT(SUCCEEDED(hr)); if (FAILED(hr)) { XY_LOG_ERROR("Failed to unlock subpic. "<<XY_LOG_VAR_2_STR(hr)); } CRect dirty_rect; hr = m_pSubPic->GetDirtyRect(&dirty_rect); ASSERT(SUCCEEDED(hr)); if (!dirty_rect.IsRectEmpty()) { if (!m_use_dst_alpha) { hr = mem_subpic->FlipAlphaValue(dirty_rect);//fixme: mem_subpic.type is now MSP_RGBA_F, not MSP_RGBA ASSERT(SUCCEEDED(hr)); if (FAILED(hr)) { XY_LOG_ERROR("Failed. "<<XY_LOG_VAR_2_STR(hr)); return hr; } } } else { hr = S_FALSE; } } m_provider->Unlock(); if (hr == S_OK) { CRect video_rect(CPoint(0,0), m_original_video_size); m_xy_sub_render_frame = DEBUG_NEW XySubRenderFrameWrapper(mem_subpic, video_rect, video_rect, now, &hr); } else { m_xy_sub_render_frame = NULL; } return hr; }
// Define the integer list CAtlList<int> myList; // Populate the list POSITION myPos = myList.AddHead(1); myPos = myList.InsertBefore(myPos, 2); myPos = myList.InsertBefore(myPos, 3); // Confirm the head value is as expected ATLASSERT(myList.GetHead() == 3);