|
-
August 20th, 2001, 04:35 PM
#1
getting animation using doc redraw
This is similar to a post that I put on the beginner thread but I haven't yet been able to get a solution.
I have a simple SDI program and I am trying to handle a message from the menu in two different ways. One way, I handle the message in CFlashView and the other way, I handle the message in CFlashDoc. What I am trying to do is make the client area of a window flash through a bunch of colors - the real point is that I want to refresh a view that uses document information from the document. I think that there are three important parts of code from the two different methods:
1) CFlashView::OnFileRun()
2) CFlashDoc::OnFileRun()
3) CFlashView::OnDraw <--- not really that important
When I do this by putting the command handler in the CFlashView, it flashes the way that I want it to. When I put the command handler in CFlashDoc, it seems to run through the entire loop and then at the end, it refreshes the screen with the same picture that you get from the view but it doesn't show the intermediate colors and thus "flash".
What do I have to modify to make the screen flash if I put the command handler in the documnet?
void CFlashView::OnFileRun()
{
CFlashDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CClientDC* pDC = new CClientDC(this);
for(int x=0;x<1000;x++)
{
pDoc->m_colorPoint++;
OnDraw(pDC);
}
}
=====================
void CFlashDoc::OnFileRun()
{
for(int x=0;x<100000;x++)
{
m_colorPoint++;
UpdateAllViews(NULL);
}
}
=====================
void CFlashView::OnDraw(CDC* pDC)
{
CFlashDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect aRect;
pDC->GetWindow()->GetClientRect(aRect);
pDC->FillSolidRect(aRect,RGB((pDoc->m_colorPoint)%255,
(pDoc->m_colorPoint*2)%255,
(pDoc->m_colorPoint*3)%255
)
);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|