Solved

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

Posted on 2007-12-05
4
1,035 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unix Command -- Challenging  question 7 105
CKEditor - will not function 7 81
What .NET URL re-routing tool did I use? 2 90
Example code 13 36
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ā€¦
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

738 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