#if wxUSE_THREADS
#include "wx/thread.h"
- // define the array of MSG strutures
- WX_DECLARE_OBJARRAY(MSG, wxMsgArray);
+ // define the list of MSG strutures
+ WX_DECLARE_LIST(MSG, wxMsgList);
- #include "wx/arrimpl.cpp"
+ #include "wx/listimpl.cpp"
- WX_DEFINE_OBJARRAY(wxMsgArray);
+ WX_DEFINE_LIST(wxMsgList);
#endif // wxUSE_THREADS
// ----------------------------------------------------------------------------
break;
}
- // now try the other hooks (kbd navigation is handled here): we start from
- // wndThis->GetParent() because wndThis->MSWProcessMessage() was already
- // called above
- for ( wnd = wndThis->GetParent(); wnd; wnd = wnd->GetParent() )
+ // now try the other hooks (kbd navigation is handled here)
+ for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
{
- if ( wnd->MSWProcessMessage((WXMSG *)msg) )
- return true;
+ if (wnd != wndThis) // Skip the first since wndThis->MSWProcessMessage() was called above
+ {
+ if ( wnd->MSWProcessMessage((WXMSG *)msg) )
+ return true;
+ }
+
+ // Stop at first top level window (as per comment above).
+ // If we don't do this, pressing ESC on a modal dialog shown as child of a modal
+ // dialog with wxID_CANCEL will cause the parent dialog to be closed, for example
+ if (wnd->IsTopLevel())
+ break;
}
// no special preprocessing for this message, dispatch it normally
wxT("only the main thread can process Windows messages") );
static bool s_hadGuiLock = true;
- static wxMsgArray s_aSavedMessages;
+ static wxMsgList s_aSavedMessages;
// if a secondary thread owning the mutex is doing GUI calls, save all
// messages for later processing - we can't process them right now because
// the message will be processed twice
if ( !wxIsWaitingForThread() || msg.message != WM_COMMAND )
{
- s_aSavedMessages.Add(msg);
+ MSG* pMsg = new MSG(msg);
+ s_aSavedMessages.Append(pMsg);
}
return true;
{
s_hadGuiLock = true;
- size_t count = s_aSavedMessages.Count();
- for ( size_t n = 0; n < count; n++ )
+ wxMsgList::compatibility_iterator node = s_aSavedMessages.GetFirst();
+ while (node)
{
- MSG& msg = s_aSavedMessages[n];
- ProcessMessage(&msg);
- }
+ MSG* pMsg = node->GetData();
+ s_aSavedMessages.Erase(node);
- s_aSavedMessages.Empty();
+ ProcessMessage(pMsg);
+ delete pMsg;
+
+ node = s_aSavedMessages.GetFirst();
+ }
}
}
#endif // wxUSE_THREADS