Solved

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

Posted on 1998-08-14
5
157 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
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 162
deburging in oracle form 12 99
java ^ examples 8 65
Capture logon name 13 73
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 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