?
Solved

A painting job...... with a View

Posted on 1998-08-14
5
Medium Priority
?
180 Views
Last Modified: 2013-11-20
Hi guys...
   I am trying to repaint (refresh) the View but from another dialog.. I have a handle to the MyAppView and I tried to call WM_PAINT using PostMessage from another dialog class, it didn't work... I also tried PostMessage with a user defined message that calls the OnDraw(CDC *pDC) of the View and it didn't work...
my code was like this-->

  ::PostMessage( hWnd, UOM_<my user defined msg>, 0,0);       *where hWnd is the View handle

I suspect that it is becuase I have yet to enter a CDC *pDC parameter value but I don't know how to do that...
Can u guys tell me how to do this or better still, a easier way to do this repainting of the view from another
dialog class???

Thnaks a lot!!
Bye.
David Chong
0
Comment
Question by:Haho
  • 2
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 120 total points
ID: 1320784
You need to invalidate the update region first. Use the following code instead of ::PostMessage.

::InvalidateRect(hWnd, NULL, TRUE);
::UpdateWindow(hWnd);

0
 
LVL 3

Expert Comment

by:Norbert
ID: 1320785
chensu was faster than I so I provide my answer as comment
but it is the same like chensu using MFC classes

If you have the CView class pointer try
  pView->Invalidate();
  pView->UpdateWindow();
if you only have the Handle try
CWnd * pView=CWnd::FromHandle(hWnd)
  pView->Invalidate();
  pView->UpdateWindow();

one of them should do the trick
0
 
LVL 1

Author Comment

by:Haho
ID: 1320786
Thanks guys... excellent answer.....

Have a nice day!!

David Chong
0
 
LVL 1

Author Comment

by:Haho
ID: 1320787
HI,

oops, I think my question is really confusing.. :)

   Err.. let me try to simplying it. is there a way for class CDialog to access a var
(by way of pointer) in CClass BUT I don't want to explicitly declare any object , globally
or locally of CClass in CDialog.. can we like reference the object instance of CClass
that is running , kind of like...  COtherClass::SomeFunction; ...
thanks...
Why? Err.... long story.. which will no doubt confuse others and u more,
but if u insist.. :)

David Chong


0
 
LVL 23

Expert Comment

by:chensu
ID: 1320788
class CClass
{
public:
    int m_nNum;
};

In another class, you must have an object or a pointer to the object of CClass in order to access its m_nNum. A data member variable belongs to an object.

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

594 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