Click here to Skip to main content
15,897,519 members

Trouble with area fixxing using ValidateRect()

Revision 1
Hello everyone

I'm trying to resolve the problem with image blinking and I almost get it ,but I got some problems.

I want to redraw all the rest of the window except only the image. I'm trying to throw the Image's rectangle(i.e.coordinates) into ValidateRect and perform rendering but somehow it doesn't work

If I just overriding OnEraseBkgnd(CDC* pDC) {return false;}
It gives me a workable code,without any flickering(especially it looks great with high-definition images like 1680x1050) . But with small pictures where all the rest window is free when I begin resize it, it lefts remains(thats why I need to redraw it)
I've tried a lot of different ways and can't make it work
All the code is in OnDraw(CDC* pDC/*pDC*/) function
1)
if(oldpathName!=pathName){
	memDC.DeleteDC();
	memDC.CreateCompatibleDC(pDC);
	cImg.Destroy();
	if(cImg.Load((LPCTSTR)pathName)!=S_OK)
		AfxMessageBox(L"Error");
	memDC.SelectObject(cImg);
	pDC->BitBlt(0, 0, cImg.GetWidth(), cImg.GetHeight(), &memDC, 0, 0, SRCCOPY);
	oldpathName=pathName;erase=true;}
	else{
		CRect s(0,0,tmpImg->width,tmpImg->height);
		////InvalidateRect(s,FALSE);
		//RedrawWindow(s,NULL,RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
		ValidateRect(&s);
		pDC->BitBlt(0, 0, cImg.GetWidth(), cImg.GetHeight(), &memDC, 0, 0, SRCCOPY);
		//RedrawWindow(s,NULL,RDW_VALIDATE | RDW_UPDATENOW | RDW_ERASENOW);


Please gimme a clue what I should change
Posted 8-Oct-12 12:33pm by JOHN 602.
Tags: ,