OSDN Git Service

Associate DMH message boxes with active dialogues.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 18 Oct 2012 13:16:15 +0000 (14:16 +0100)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 18 Oct 2012 13:16:15 +0000 (14:16 +0100)
ChangeLog
src/guidmh.cpp

index 99b55b5..0d76564 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-10-18  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
+       Associate DMH message boxes with active dialogues.
+
+       * src/guidmh.cpp (last_active_popup): New static inline function.
+       (dmhTypeGUI::dispatch_message): Use it.
+
+2012-10-18  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
        Fix Diagnostic Message Handler initialisation logic.
 
        * src/dmh.cpp (dmh_init) [DMH_SUBSYSTEM_GUI]: Correct a logic error;
index 32aed2d..df8c5d9 100644 (file)
@@ -127,6 +127,18 @@ int dmhTypeGUI::notify( const dmh_severity code, const char *fmt, va_list argv )
   }
 }
 
+static inline HWND last_active_popup( HWND owner )
+{
+  /* Local helper function to ensure that diagnostic MessageBox
+   * dialogues are assigned to the most recently active pop-up,
+   * if any, invoked by the primary owner application window.
+   */
+  HWND popup = GetLastActivePopup( owner );
+  if( IsWindow( popup ) )
+    return popup;
+  return owner;
+}
+
 int dmhTypeGUI::dispatch_message( int len )
 {
   /* Helper used by both the control() and notify() methods,
@@ -172,7 +184,7 @@ int dmhTypeGUI::dispatch_message( int len )
 
     /* Dispatch the message...
      */
-    MessageBox( owner, msgbuf, progname, status );
+    MessageBox( last_active_popup( owner ), msgbuf, progname, status );
 
     /* ...then release the heap memory used to format it.
      */