I have a DocumentWindow and show a modal DialogWindow if a button is clicked. The modal DialogWindow blocks the DocumentWindow as expected if I try to give the DocumentWindow focus by clicking on it.
The problem is that I can bring the blocked DocumentWindow to front when clicking its taskbar button or Alt+Tab’ing to it. If I click afterwards on the DocumentWindow itself the modal DialogWindow gets in front of it again.
The fix for this problem is to bring the modal DialogWindow to front after the blocked DocumentWindow has been activated. This simple change to the way WM_ACTIVATE is handled in Win32ComponentPeer::peerWindowProc():
[code] case WM_ACTIVATE:
if (LOWORD (wParam) == WA_ACTIVE || LOWORD (wParam) == WA_CLICKACTIVE)
{
modifiersAtLastCallback = -1;
updateKeyModifiers();
if (isMinimised())
{
component->repaint();
handleMovedOrResized();
if (! isValidMessageListener())
return 0;
}
if (LOWORD (wParam) == WA_CLICKACTIVE
&& component->isCurrentlyBlockedByAnotherModalComponent())
{
int mx, my;
component->getMouseXYRelative (mx, my);
Component* const underMouse = component->getComponentAt (mx, my);
if (underMouse != 0 && underMouse->isCurrentlyBlockedByAnotherModalComponent())
Component::getCurrentlyModalComponent()->inputAttemptWhenModal();
return 0;
}
handleBroughtToFront();
-
if (component->isCurrentlyBlockedByAnotherModalComponent())
-
Component::getCurrentlyModalComponent()->toFront (true); return 0; } break;[/code]