Update only a particial area of a View with UpdateAllViews(...)
-
Hi, i want to update only a part of a view with UpdateAllViews(). I read that the simpliest way is to call UpdateAllViews() from the doc and pass a CRect to the view's OnUpdate(). The rect which is passed to the view's OnUpdate() ist the part which is updated. But it wont work :(( , I tried it for some hours now, could you helpme? :confused: Perhaps you know a tut which covers this problem i only found the simple UpdateAllViews(NULL)samples ? Here is some source from me which updates the whole view doc.cpp:
CString CMyDoc::LoadFile(CString cstrSearchString, CString *ptrArrFileNames, CString cstrFileExtension, int iZaehler)
{
m_iZaehler = iZaehler;
ptrMlf->loadmyfile (cstrSearchString + m_ptrArrFileNames[iZaehler],cstrFileExtension);
m_cstrText = ptrMlf->lf_cstrText;UpdateAllViews(NULL); // Calls OnUpdate of the view and updates the whole view !!! return m\_cstrAusgabe;
}
Here the code from the view.cpp:
void CMyView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CTheReaderDoc *pDoc = GetDocument ();
CRichEditCtrl &rCtrl = GetRichEditCtrl();
rCtrl.SetWindowText (pDoc->m_cstrAusgabe);
rCtrl.SetFont(pDoc->m_ptrFont);
rCtrl.SetModify(TRUE);
}Many thanx & best regards ;) ShadowEater
-
Hi, i want to update only a part of a view with UpdateAllViews(). I read that the simpliest way is to call UpdateAllViews() from the doc and pass a CRect to the view's OnUpdate(). The rect which is passed to the view's OnUpdate() ist the part which is updated. But it wont work :(( , I tried it for some hours now, could you helpme? :confused: Perhaps you know a tut which covers this problem i only found the simple UpdateAllViews(NULL)samples ? Here is some source from me which updates the whole view doc.cpp:
CString CMyDoc::LoadFile(CString cstrSearchString, CString *ptrArrFileNames, CString cstrFileExtension, int iZaehler)
{
m_iZaehler = iZaehler;
ptrMlf->loadmyfile (cstrSearchString + m_ptrArrFileNames[iZaehler],cstrFileExtension);
m_cstrText = ptrMlf->lf_cstrText;UpdateAllViews(NULL); // Calls OnUpdate of the view and updates the whole view !!! return m\_cstrAusgabe;
}
Here the code from the view.cpp:
void CMyView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CTheReaderDoc *pDoc = GetDocument ();
CRichEditCtrl &rCtrl = GetRichEditCtrl();
rCtrl.SetWindowText (pDoc->m_cstrAusgabe);
rCtrl.SetFont(pDoc->m_ptrFont);
rCtrl.SetModify(TRUE);
}Many thanx & best regards ;) ShadowEater
UpdateAllViews() gives you TWO parameters that get passed to all the CView::OnUpdate() calls. What about passing a pointer to a CRect in one of those paramters? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hi, i want to update only a part of a view with UpdateAllViews(). I read that the simpliest way is to call UpdateAllViews() from the doc and pass a CRect to the view's OnUpdate(). The rect which is passed to the view's OnUpdate() ist the part which is updated. But it wont work :(( , I tried it for some hours now, could you helpme? :confused: Perhaps you know a tut which covers this problem i only found the simple UpdateAllViews(NULL)samples ? Here is some source from me which updates the whole view doc.cpp:
CString CMyDoc::LoadFile(CString cstrSearchString, CString *ptrArrFileNames, CString cstrFileExtension, int iZaehler)
{
m_iZaehler = iZaehler;
ptrMlf->loadmyfile (cstrSearchString + m_ptrArrFileNames[iZaehler],cstrFileExtension);
m_cstrText = ptrMlf->lf_cstrText;UpdateAllViews(NULL); // Calls OnUpdate of the view and updates the whole view !!! return m\_cstrAusgabe;
}
Here the code from the view.cpp:
void CMyView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CTheReaderDoc *pDoc = GetDocument ();
CRichEditCtrl &rCtrl = GetRichEditCtrl();
rCtrl.SetWindowText (pDoc->m_cstrAusgabe);
rCtrl.SetFont(pDoc->m_ptrFont);
rCtrl.SetModify(TRUE);
}Many thanx & best regards ;) ShadowEater
CrocodileBuck wrote:
I read that the simpliest way is to call UpdateAllViews() from the doc and pass a CRect to the view's OnUpdate(). The rect which is passed to the view's OnUpdate() ist the part which is updated. But it wont work , I tried it for some hours now
The code you posted is not trying to use a CRect so how are we supposed to know what you are trying that is not working? :confused:
led mike
-
CrocodileBuck wrote:
I read that the simpliest way is to call UpdateAllViews() from the doc and pass a CRect to the view's OnUpdate(). The rect which is passed to the view's OnUpdate() ist the part which is updated. But it wont work , I tried it for some hours now
The code you posted is not trying to use a CRect so how are we supposed to know what you are trying that is not working? :confused:
led mike
Thx for yor quick replies, here the code which tries to pass a pointer to CRect: Doc.cpp:
CString CMyDoc::LoadFile(CString cstrSearchString, CString *ptrArrFileNames, CString cstrFileExtension, int iZaehler)
{
m_iZaehler = iZaehler;
ptrMlf->loadmyfile (cstrSearchString + m_ptrArrFileNames[iZaehler],cstrFileExtension);
m_cstrAusgabe = ptrMlf->lf_cstrAusgabe;CRect \*MyRect; MyRect(100, 100, 100, 100); CObject\* pHint = NULL; pHint = reinterpret\_cast<cobject\*>(MyRect); UpdateAllViews(NULL, 1, pHint); return m\_cstrAusgabe;
}
Many many thanx and best regards Croc
-
Thx for yor quick replies, here the code which tries to pass a pointer to CRect: Doc.cpp:
CString CMyDoc::LoadFile(CString cstrSearchString, CString *ptrArrFileNames, CString cstrFileExtension, int iZaehler)
{
m_iZaehler = iZaehler;
ptrMlf->loadmyfile (cstrSearchString + m_ptrArrFileNames[iZaehler],cstrFileExtension);
m_cstrAusgabe = ptrMlf->lf_cstrAusgabe;CRect \*MyRect; MyRect(100, 100, 100, 100); CObject\* pHint = NULL; pHint = reinterpret\_cast<cobject\*>(MyRect); UpdateAllViews(NULL, 1, pHint); return m\_cstrAusgabe;
}
Many many thanx and best regards Croc
That code compiles? Maybe try something simpler:
CRect MyRect(100, 100, 100, 100); CObject\* pHint = (CObject\*)&MyRect; UpdateAllViews(NULL, 1, pHint);
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
That code compiles? Maybe try something simpler:
CRect MyRect(100, 100, 100, 100); CObject\* pHint = (CObject\*)&MyRect; UpdateAllViews(NULL, 1, pHint);
Mark Salsbery Microsoft MVP - Visual C++ :java:
Thanx, it will work, i could now pass the CRect! Simple is Simply the best way ;) But do you know what i have to do in the OnUpdate of the viw.cpp ? The view will not automatically update only the rect area ? I men when i print text in my view and then load new text my version of UpdateAllViews should only update the rect ??? But how? Sorry for my stupid question :confused: :-O but i m really confused ! Many thanx Croc
-
Thanx, it will work, i could now pass the CRect! Simple is Simply the best way ;) But do you know what i have to do in the OnUpdate of the viw.cpp ? The view will not automatically update only the rect area ? I men when i print text in my view and then load new text my version of UpdateAllViews should only update the rect ??? But how? Sorry for my stupid question :confused: :-O but i m really confused ! Many thanx Croc
A simple call to InvalidateRect() in your OnUpdate() overrides should do it.
void CMyView::OnUpdate(CView* pSender, LPARAM /*lHint*/, CObject* pHint)
{
InvalidateRect((CRect*)pHint, TRUE);
}Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
A simple call to InvalidateRect() in your OnUpdate() overrides should do it.
void CMyView::OnUpdate(CView* pSender, LPARAM /*lHint*/, CObject* pHint)
{
InvalidateRect((CRect*)pHint, TRUE);
}Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Hi Mr. Salsbery, i tried
InvalidateRect((LPCRECT)pHint, TRUE);
but it won't work :( Thanx for all your help Croc
-
A simple call to InvalidateRect() in your OnUpdate() overrides should do it.
void CMyView::OnUpdate(CView* pSender, LPARAM /*lHint*/, CObject* pHint)
{
InvalidateRect((CRect*)pHint, TRUE);
}Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Sry, i was too fast, but your version won't work Too ! Thax for all your help & best regards Croc
-
Hi Mr. Salsbery, i tried
InvalidateRect((LPCRECT)pHint, TRUE);
but it won't work :( Thanx for all your help Croc
What does "won't work" mean? If you're using a rect of (100,100,100,100) then nothing will happen, since the rect has no dimensions (width and height are 0). Try a valid rect! :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
What does "won't work" mean? If you're using a rect of (100,100,100,100) then nothing will happen, since the rect has no dimensions (width and height are 0). Try a valid rect! :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Hi, yes thats right but i tried it with
CRect MyRect(0,0, 200, 150); CObject\* pHint = (CObject\*)&MyRect;
and this fails too! Manx thanx and best regards Croc
-
Hi, yes thats right but i tried it with
CRect MyRect(0,0, 200, 150); CObject\* pHint = (CObject\*)&MyRect;
and this fails too! Manx thanx and best regards Croc
What does "fails" mean? Doesn't compile? Crashes at runtime? Nothing happens? It marks the area for updating. The next WM_PAINT message will update that area. If the same exact data is drawn as on the last WM_PAINT, you're not going to see a difference.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
What does "fails" mean? Doesn't compile? Crashes at runtime? Nothing happens? It marks the area for updating. The next WM_PAINT message will update that area. If the same exact data is drawn as on the last WM_PAINT, you're not going to see a difference.
Mark Salsbery Microsoft MVP - Visual C++ :java:
I Mean nothin happens! Ahhh the InvalidateRect() hasn't to do something with the text printed in the RTFCtrl on the View ???!!! What can i do that i can see a little difference ????? Many many thanx for your help and best regards :) Croc
-
I Mean nothin happens! Ahhh the InvalidateRect() hasn't to do something with the text printed in the RTFCtrl on the View ???!!! What can i do that i can see a little difference ????? Many many thanx for your help and best regards :) Croc
CrocodileBuck wrote:
What can i do that i can see a little difference ?
You need to change something between calls to UpdateAllViews() if you want to see something different in the view. What are your views drawing? Something from the document? If so, change the document.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
CrocodileBuck wrote:
What can i do that i can see a little difference ?
You need to change something between calls to UpdateAllViews() if you want to see something different in the view. What are your views drawing? Something from the document? If so, change the document.
Mark Salsbery Microsoft MVP - Visual C++ :java:
I will only print Text (SetWindowText) in the View !!!???? Many many thanks and best regards Croc
-
I will only print Text (SetWindowText) in the View !!!???? Many many thanks and best regards Croc
Only you know what's going on in your views. The text data must be coming from somewhere... Change it and update the views! And make sure changing it doesn't already cause an update implicitly, or you still won't see anything. If the view is a window not in your control (where you don't do the painting, like an edit control), then you may not have control over updating regions of the window. If you are doing the painting in your view, look at the invalid rect in the WM_PAINT handler - you should see that your update rect is there. What you do with that info in your painting code is up to you. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Only you know what's going on in your views. The text data must be coming from somewhere... Change it and update the views! And make sure changing it doesn't already cause an update implicitly, or you still won't see anything. If the view is a window not in your control (where you don't do the painting, like an edit control), then you may not have control over updating regions of the window. If you are doing the painting in your view, look at the invalid rect in the WM_PAINT handler - you should see that your update rect is there. What you do with that info in your painting code is up to you. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Ok. Thanx, iwill try it ! Tomorrow i will mail my success or ... ;( ;) Many many thanx and best regards Croc
-
I will only print Text (SetWindowText) in the View !!!???? Many many thanks and best regards Croc
What class is your view derived from?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Only you know what's going on in your views. The text data must be coming from somewhere... Change it and update the views! And make sure changing it doesn't already cause an update implicitly, or you still won't see anything. If the view is a window not in your control (where you don't do the painting, like an edit control), then you may not have control over updating regions of the window. If you are doing the painting in your view, look at the invalid rect in the WM_PAINT handler - you should see that your update rect is there. What you do with that info in your painting code is up to you. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
You are in deep deep shit at this point dude. Maybe you should just treat the buck to a Filet-O-Fish and call it a day. :-D I'm outta here, have a great weekend! :beer:
led mike
Cheers! :beer:
Mark Salsbery Microsoft MVP - Visual C++ :java: