读取指定文件夹下的bmp格式图片,将读取的每幅图片路径保存到一个列表中
list<CString> pictureList;
list<CString>::iterator i;
//ff是定义的CFileFind变量
BOOL bf = ff.FindFile(L"D://picture//*.bmp");while(bf){ bf = ff.FindNextFileW(); CString filePath = ff.GetFilePath (); pictureList.push_back (filePath); }
//读取每个路径,显示图片
for( i = pictureList.begin(); i != pictureList.end(); i++){ BeginWaitCursor();
CString filePathName = *i; CCameraView* pCameraView=(CCameraView*)m_wndSplitterL.GetPane(0,0); if(!pCameraView->m_CameraImage .AttachFromFile (filePathName)) { EndWaitCursor(); AfxMessageBox(L"打开文件时出错!请确保正确的位图(*.bmp,*.jpg,*.GIF)文件类型。"); return; }
//刷新视图Sleep(1000);pCameraView->Invalidate();
//处理显示DoEvent();
}
//功能相当于VB的DoEvent()功能,处理其他事件
void DoEvent()
{
MSG msg;
while(::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE))
{
if (!AfxGetApp()->PumpMessage())
return;
}
}