|
-
May 25th, 1999, 05:00 PM
#1
CView
Hello,
How can I Invalidate the view window from another class? I'm using Visual C++ 6.0 and I have a combo box, which is at the top of the view, and when I select something in the combo box, I want to update the view.
Thanks for any help!
Matt
-
May 25th, 1999, 11:31 PM
#2
Re: CView
CView is derived from CWnd
use base class functions (like RedrawWindow)
-
May 26th, 1999, 01:57 AM
#3
Re: CView
For an SDI app:
--- CFrameWnd *pWndMain ;
CView *pView = NULL ;
pWndMain = (CFrameWnd *)AfxGetMainWnd();
if (pWndMain != NULL)
pView = pWndMain->GetActiveView();
if (pView != NULL)
pView->InvalidateRect(NULL);
---
For an MDI app:
--- CFrameWnd *pWndChild = NULL ;
CMDIFrameWnd *pWndMain ;
CView *pView = NULL ;
pWndMain = (CMDIFrameWnd *)AfxGetMainWnd();
if (pWndMain != NULL)
pWndChild = pWndMain->MDIGetActive();
if (pWndChild != NULL)
pView = pWndChild->GetActiveView();
if (pView != NULL)
pView->InvalidateRect(NULL);
---
These assume that the view you want to update is the currently-active. If you want to update ALL views simultaneously, use GetActiveDocument() instead of GetActiveView() and call CDocument's UpdateAllViews() method.
If you only want to update one view, and you can't rely on it being the active one, you will have to find some way of distinguishing between the views, and then use CDocTemplate's GetFirstDocPosition() and GetNextDoc() to iterate through the documents in your app, and then CDocument's GetFirstViewPosition() and GetNextView() to iterate through the views associated with each document. You can then test the view to see if it is the right one.
Does this help?
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
|