Solved

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

Posted on 1998-08-14
5
165 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
[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
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 30 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 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