?
Solved

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

Posted on 1998-08-14
5
Medium Priority
?
168 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 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

762 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