Solved

How to update the parent of a modeless child dialog window

Posted on 2006-06-19
5
439 Views
Last Modified: 2013-11-20
Hello

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);
m_dlg->ShowWindow(SW_SHOWNORMAL);

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?

Thanks
0
Comment
Question by:oroussea
[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
5 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 55 total points
ID: 16936632
When modeless dialog is active, parent window must continue to handle WM_TIMER messages. You don't need to do anything special for this.
0
 

Author Comment

by:oroussea
ID: 16936652
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?
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16939939
You don't need to tell anything, parent continues to handle events in any case.
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 35 total points
ID: 16940182
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 ) )
      {  
            ::TranslateMessage(&msg);
            ::DispatchMessage(&msg);
      }
}

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.
0
 
LVL 1

Assisted Solution

by:ramesh_hyd_ap
ramesh_hyd_ap earned 35 total points
ID: 16942794
Hi,

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 :

BEGIN_MESSAGE_MAP ....
ON_MESSAGE(WM_UD_PARENTUPDATE ,OnUpdateParent)
END_MESSAGE_MAP..


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


Thanks,
Ramesh.


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

Suggested Solutions

Title # Comments Views Activity
Prevent this page from creating additional dialogs. 3 720
Line meaning 9 91
Detect file exist or not 3 202
Problem to App 4 119
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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