How to update the parent of a modeless child dialog window


I have a class that inherit from CScrollView which creates a modeless dialog box when the user clicks on a button:

m_dlg = new CActorPropertiesDlg;
m_dlg->Create(IDD_PROPERTIES, this);

What i want to achieve is the parent must still be refreshed when the focus is on the modeless dialog... right now, its only redrawn when the focus is on the parent.

My parent CScrollView object is refreshed using SetTimer(1, 100, NULL)... and in OnTimer( ), i use Invalidate.

How could i tell the modeless dialog to continue to update its parent each 100 ms?

Who is Participating?
AlexFMConnect With a Mentor Commented:
When modeless dialog is active, parent window must continue to handle WM_TIMER messages. You don't need to do anything special for this.
orousseaAuthor Commented:
How can i tell the parent to do so?

Because its not like i told the parent to stop handling the timer event...

Should i set something to tell the parent to process the events even though it doesn't have focus?
You don't need to tell anything, parent continues to handle events in any case.
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
I'm going to make a wild guess that your modeless dialog is performing a lengthy operation.  This will 'stop' the normal message handling in the thread (because it is very busy).  A patch is as follows.

In the processing in the modeless dialog
while(...)   <<--------------- or for loop or whatever
//work work work
DoEvents();   <<------------------------------------

void DoEvents()
      MSG msg;  
      while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE ) )

This forces the message queue to be processed - gives timer and paint messages a chance to work.

If I have guessed correctly then you ought to consider using threads to perform the operation.
ramesh_hyd_apConnect With a Mentor Commented:

Create a user defined message like

  #define WM_UD_PARENTUPDATE           WM_USER+10

In the modeless dialog class has you are doing some operation so whenver you want to update parent
send the message to the parent as :

::SendMessage ( h_wndParent, WM_UD_PARENTUPDATE , NULL, NULL );

Handle the message handler in the parent window class as :


LRESULT OnUpdateParent (WPARAM wParam,LPARAM lParam)
  // write code here what ever you want to do in the parent.
  return 0;


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.