473,799 Members | 2,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mfc view not updating

17 New Member
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 4988
Studlyami
464 Recognized Expert Contributor
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(tru e); or just the control area pDoc->Invalidate(tru e);
Feb 12 '08 #2
YouPoP
17 New Member
pDoc->Invalidate(tru e);
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
1579
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 number of rows, so that old rows are discarded in favor of new rows if the limit is reached. My use case is very similar to that of the SQL Profiler GUI - I'm going to be receiving a large amount of data from a server that I want to display....
2
8334
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 is the problem. What's happening is that I'm updating fields that are part of view. I'm only updating fields in one table of the view and this works fine in the development environment.
6
4619
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" - There's a Class, which we'll call "classDocument" Thus, when an instance of each the form and the class are instantiated, they each will hold the same data, albeit be independent of each other. To keep the two in perfect sync with each other,...
3
1314
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 via a View - makes perfect sense. But because I used a View, I can't use the CommandBuilder. I have to specify my own Commands which will in some cases be huge and complex. This seems crazy - what if I change the db structure? And because I...
6
5211
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 table adaptor. I would like to update the b ase tables thorugh the view. How do i do this? FYI: I have some reserarch on how to handle updating multiple tables and making sure I don't break referential integrity, yet in this case I will not be...
2
1414
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 several objects to display in the view. And I can hide some objects in the view. My question is that: May I need to store the hide status of an object
3
1590
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
2491
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 table "employee" the trigger "tr_view_emp_iu" will not be executed. create or replace view view_employee as select e.emp_id, e.first_Name, e.last_name from employee e
2
2194
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 and the code behind, but no graphical design view, which is pretty fundamental for development. I have .net framework 2.0 service pack 1 installed. When I click on view designer it appears to be locked, although there is no message. This happens on...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.