WMDIParent Close handler
There is a bug in WMDIParent in the Close handler, which performs (or should) a WQueryCloseEvent on all children.
The Win32 message handler for WM_MDINEXT returns 0 but the component code uses this as the next MDI child handle. So the loop executes only once for the active child.
The code *should* use WM_MDIGETACTIVE after this call to get the child handle and process all child windows. If you have more than one open child window that needs saving, only the first gets a WQueryCloseEvent. The following code fixes the bug in WMDIParent for the WQueryCloseEvent handling.
I chose not to fix the Destroy problem which also exists for the same reason because by following P++ methods for MDI programs it's not needed.
// This stops double QueryClose events
RemoveEventHandler( WQueryCloseEvent, WEventHandlerCast(WMDIParent,
DefaultEventHandler) );
SetEventHandler( WQueryCloseEvent, this, WEventHandlerCast(Form1,
Form1_QueryClose) );
WMDIChild *activeChild;
WMDIChild *child;
// Ask all of the children first if its OK to close
activeChild = GetActiveChild( NULL );
for( child = activeChild; child != 0 ; )
{
if( child->CallEventHandler( WQueryCloseEvent, this ) )
return TRUE;
ActivateNext();
child = GetActiveChild( NULL );
if( child == activeChild )
break;
}
return FALSE;
The bug exists in Power 2.5, 2.1 and probably in all previous versions.
Submitted by Bill Auerbach