473,243 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,243 software developers and data experts.

mfc view not updating

17
Hi, I am doing an MFC MDI application with VS 8.0. I am using the default document view plus a formview ans show both of them in the view using a splitter.
In the formview there is an event onBtnclicked that displays some valued entered by the user in the document. Here is the code in my formview:
Expand|Select|Wrap|Line Numbers
  1. // MyForm.cpp
  2.  
  3. void CMyForm::OnBnClickedButtonok()
  4. {
    CTP1Doc *pDoc = (CTP1Doc *)GetDocument();
  5. pDoc->hello += "BONJOUR";
  6. pDoc->UpdateAllViews(this);}
  7.  
  8.  
  9. // TP1View.cpp 
  10.  
  11. void CTP1View::OnDraw(CDC* pDC)
  12. {
    CTP1Doc* pDoc = GetDocument();
  13. CTP1Doc* pDoc2 = GetDocument();
  14. ASSERT_VALID(pDoc);
  15. // TODO: add draw code for native data here
  16. pDC->TextOut(10,10,pDoc->hello);
  17. pDC->TextOut(10,25,pDoc2->hello2);}
  18.  
  19.  
the application is updating the view (and drawing the text) only after the application itself has been hidden (under another application, or minimized) and showing again.

Also, i tried doing it in a third class

Expand|Select|Wrap|Line Numbers
  1. //MatriceCalculs.cpp
  2.  
  3. float CMatriceCalculs::VerifSolution(float *matriceA[2][2], float *matriceB[2][1])
  4. {
    CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; 
  5. CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); 
  6. CTP1View *pView = (CTP1View *)pChild->GetActiveView();
  7. CTP1Doc *pDoc = pView->GetDocument();
  8. pDoc->hello += "// y = kekchose ";
  9. return 1.0;}
  10.  
  11.  
and the problem is the same, it does not update the view in real time.

Thanks for helping!
Feb 11 '08 #1
2 4937
Studlyami
464 Expert 256MB
you need to invalidate the object after you have finished updating it (this will make a call to OnPaint()). You can invalidate the entire object this->Invalidate(true); or just the control area pDoc->Invalidate(true);
Feb 12 '08 #2
YouPoP
17
pDoc->Invalidate(true);
is not working (Invalidate not a member of TP1Doc)
but Invalidate() in the OnUpdate method is working fine

thank you very much for your reply!
Feb 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chris Mullins | last post by:
I'm building a GUI that needs to be able to view a large amount of text arranged in rows. Large being anywhere from a few hundred lines through a few hundred thousand. I need a way to "cap" the max...
2
by: fig000 | last post by:
Hi, I have an application that's running fine on development servers (web and database-sql server 2000). I'm updating a record through a third party component but I don't think the component...
6
by: Robert W. | last post by:
I'm building my first major C# program and am try to use best practices everywhere. So I've implemented the "Document/View Model" whereby: - There's a Windows Form, which we'll call "formView" -...
3
by: Doug | last post by:
Scenario: I select data from a SQL Server View which links 3 tables, into a single dataset table. I update some of those fields on a web form. When I want to update the db, clearly I can't update...
6
by: Greg P | last post by:
I am using VS2005 and have been learning a ton about databinding. I know that when you drag a view from the datasource window (creating a dataGridView) that an update method is not added to the...
2
by: shuisheng | last post by:
Dear All, I am learning the document/view design. The document stores data and provides GUI-independent operations upon it; while the views display and manipulate the data. Assume I have...
3
by: Phung | last post by:
Hi friend ! i want to ask you about view. will the view data be updated automatically when we insert or update the physical table or it is updated when we execute the view ?
0
by: marieoutayek | last post by:
Hi, I have a problem and I hope that you help me : I have a trigger "tr_view_emp_iu" INSTEAD OF a view "view_employee" the problem is if the changes is done on the field "first_name" in the...
2
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi, I have just installed visual studio 2005 professional edition (evaluation version). However it will not allow me to view webforms in a website project in design view. I can just see the HTML...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.