Solved

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

Posted on 1998-08-14
5
155 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 30 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks guys... excellent answer.....

Have a nice day!!

David Chong
0
 
LVL 1

Author Comment

by:Haho
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maxBlock challenge 30 99
bigDiff challenge 17 74
matchUp  challenge 6 48
firstChar challenge 13 82
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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

10 Experts available now in Live!

Get 1:1 Help Now