Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling OnDraw() to redraw window 2

Status
Not open for further replies.

edmund1978

Programmer
Jan 25, 2001
58
GB
I need to update my main document view window (in MFC program) using my code in OnDraw in myView class. This needs to be done when a button in one of my dialogs is pressed. I have a message handler but don't know how to call OnDraw (what to put as parameter). I've seen InvalidateRectacngle(..,..) mentioned, but couldn't make this work properly.
 
If you have a pointer to the doc, you can do this:
Code:
   pDoc->UpdateAllViews(NULL);
If you have a pointer to the view you can do this:
Code:
   pView->Invalidate();
If you have neither, you can get a pointer to the view (in a SDI app):
Code:
   CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();
   CView* pView = pMainWnd->GetActiveView();
or if you're working in a MDI app:
Code:
   CMDIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd();
   CFrameWnd* pChild = pMainWnd->MDIGetActive();
   CView* pView = pChild->GetActiveView();

CWnd::Invalidate() will erase the background and redraw the entire client area of a view. Invalidate(FALSE) will only redraw (background will not be erased).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top