Hello shabir... i have a question about picture loading...
i have build this engine which switches pictures on a Frame and i want it to be in a 25 fps rate, how can i be done?

here is my code:


Code:
BOOL MovieEngine::paintCurrFrame(BOOL onPaint)
{
	PAINTSTRUCT ps;	
	HDC hDC;
	hDC = ::BeginPaint(m_paintTarget->m_hWnd, &ps);
	HDC memDC = CreateCompatibleDC(hDC);
	m_jpegRect.bottom=m_offsetY+m_currFrame->GetHeight(); //m_currFrame is a cximage object
	m_jpegRect.right=m_offsetX+m_currFrame->GetWidth();
	m_paintTarget->GetClientRect(m_clientRect);
	HBITMAP hMemBmp = CreateCompatibleBitmap(hDC,  m_clientRect.Width(),  m_clientRect.Height());
	HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC, hMemBmp);
	FillRect(memDC,m_clientRect,(HBRUSH) (COLOR_WINDOW));
	if(m_playing)
	         m_currFrame->Draw(memDC,m_jpegRect);
	BitBlt(hDC, 0, 0, m_clientRect.Width(), m_clientRect.Height(), memDC, 0, 0, SRCCOPY);
	SelectObject(memDC, hOldBmp);
	::EndPaint(m_paintTarget->m_hWnd, &ps);
	DeleteObject(hMemBmp);
	if(!onPaint){
		m_paintTarget->InvalidateRect(m_jpegRect);
		m_paintTarget->RedrawWindow(m_jpegRect);
	}
	return TRUE;
}
this is the engine itself as a thread:

Code:
UINT MovieEngine::playThread(LPVOID engine)
{
	MovieEngine* thisEngine=(MovieEngine*)engine;
	if(thisEngine->m_buffComplete){
		while (thisEngine->m_movieBuff.size()>0)//m_movieBuff is a vector of pointers to cximages (hance the movie).
		{
			thisEngine->m_currFrame=thisEngine->m_movieBuff.front();
			thisEngine->m_movieBuff.pop();
			thisEngine->paintCurrFrame(FALSE); //function above
			delete thisEngine->m_currFrame;
			Sleep(40);// 40 milisec is the time needed to get 25 fps rate but all the picture switching takes time, so i need 40-switch_time...
		}
	}
	return 0;
}
ofcourse there is a loading thread (to keep buffer full untill the movie ends) while playing but it is irelevant for now.
i hope the code is clear, couse i am new to mfc and visual at all.
i managed to make it play but nothing deterministic. sometimes it plays faster than 25 fps sometimes slower.... i donno what to do
Second year SE student.