Why disabling the parent window also disables child modeless dialo

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the MDI MFC application ported to .NET.
Now this application include mixed managed/unmanaged code.

The application displays progress dialog with the cancel button
during lenghtly operation. This progress dialog implemented as
modeless to allow user to cancel the lenghtly operation if he
wishes. At the same time I disable mainframe window to prevent
user from clicking on the menu bar.

Here is the segment of the code:

void CCommProgressDialog::Show(CWnd* pParent/*=NULL*/ )
{
if(!::IsWindow(m_hWnd) )
{
if(Create(IDD, pParent ) )
{
m_pParentWnd = pParent ; // Create not set it (MFC Bug ??)

SetText("" ) ;
SetProgressText("" ) ;

CenterWindow();
ShowWindow(SW_SHOW ) ;
UpdateWindow() ;
SetFocus() ;

if(pParent )
{
pParent->EnableWindow(FALSE ) ;
}
}
}
}

I notice recently that cancel button on that dialog doesn't work.
In fact the dialog is simply disable, you can't even move it.
I isolated the problem to the following code
if(pParent )
{
pParent->EnableWindow(FALSE ) ;
}

Can anyone explain, why disabling the parent window also disabling
the child modeless dialog? Has anyone experienced such problem?
Thanks
 
This is correct behaviour. When parent window is disabled, children are
disabled automatically. When parent window is hidden, childrent will hide
too. To keep parent disabled and child enabled, use modal window.
-Praveen
 
Thank you for your response.

Could you provide any link to msdn or other source confirming that "When
parent window is disabled, children are disabled automatically". I never
heard about this before. The situation was definitely different in VC++ 6.0.
Is it new feature of .NET?

Thanks
Steve
 
Thank you for your response.

Could you provide any link to msdn or other source confirming that "When
parent window is disabled, children are disabled automatically". I never
heard about this before. The situation was definitely different in VC++ 6.0.
Is it new feature of .NET?

There are two types of child windows, and the Windows documentation
doesn't always differentiate properly.

Every created window has a parent (passed to CreateWindow or
CreateWindowEx). But what are often referred to as "child windows" are
only those that have the WS_CHILD flag set. These are windows that
exist within the parent window's client area (and are restricted
there).

Sometimes Windows documentation uses "child" to refer to any owned
window; at other times it means a real (WS_CHILD) child. Divining the
difference brings fame, fortune and true guru status!

I have not seen any difference in the treatment of my child and Child
windows between VC 6.0 and VC.NET 2003. I would think the differences,
if any, would be between OS versions instead, or simply nomenclature.
(My code is all Win32 API C/C++; no MFC or managed code bullshit.)
 
Back
Top