Solved

MFC,C++: Updating a view without calling its documents UpdateAllViews

Posted on 2007-12-05
4
977 Views
Last Modified: 2013-12-14
I would like to update an MFC view when it is about to be displayed. I can only do this though a generic CView pointer, so the only functions of my own I can call are overloaded functions. I essentially want to call OnUpdate(), but cannot, as it is private. Only the framework may call OnUpdate(). That being the case, how can I update a single view, without calling my document's UpdateAllViews()?

Regards,
Sternocera
0
Comment
Question by:sternocera
  • 2
  • 2
4 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 20411306
Two ways.
Use the UpdateAllViews and use lHint / pHint to stop views being pdated that you don't want updating.
Or in the OnUpdate call a public function eg. UpdateThisView, then for just updating one view call this directly pView->UpdateThisView();
0
 

Author Comment

by:sternocera
ID: 20411372
Andy,

I cannot know in advance exactly what sort of object my generic CView* will point to, which is why it is just a generic CView* , so I can't call anything that is not a CView member function. A bunch of views exist on the heap, and my generic CView* points to the currently viewed one.

I guess that just leaves the Hint method.

0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 20411460
Nope - you can use a custom message eg WM_APP+123.  Pass it to the view in a SendMessage (or PostMessage) and it will be handled if the view knows how to respond to that message else it will end up in the great bit bucket in the bowels of windows.
0
 

Author Comment

by:sternocera
ID: 20411549
You're right - I should just send a custom message to have the view update,

very colourful analogy :-)

Thanks
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seveā€¦
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now