]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxTopLevelWindow::RequestUserAttention(); documented it and implemented it...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 7 Sep 2004 21:02:55 +0000 (21:02 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 7 Sep 2004 21:02:55 +0000 (21:02 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29044 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/tlw.tex
include/wx/msw/toplevel.h
include/wx/toplevel.h
src/msw/toplevel.cpp

index c721c433f63db81b7fa3373239df8ccd659620fe..1cc4baf929d9c90aa722007b74c2847956d05325 100644 (file)
@@ -224,6 +224,7 @@ All (GUI):
 - added status bar fields styles support (Tim Kosse)
 - added samples/splash
 - added support for stock buttons
+- added wxTopLevelWindow::RequestUserAttention()
 
 Unix:
 
index 71ae9bc30073ec8816c3a5d6aecbf64e5596781d..f2e2fa1c038139aa929e1839ecd035b3c7e20903 100644 (file)
@@ -116,6 +116,24 @@ This function only works under Windows.
 \helpref{wxTopLevelWindow::Iconize}{wxtoplevelwindowiconize}
 
 
+\membersection{wxTopLevelWindow::RequestUserAttention}\label{wxtoplevelwindowrequestuserattention}
+
+\func{void}{RequestUserAttention}{\param{int }{flags = wxUSER\_ATTENTION\_INFO}}
+
+Use a system-dependent way to attract users attention to the window when it is
+in background.
+
+\arg{flags} may have the value of either \texttt{wxUSER\_ATTENTION\_INFO}
+(default) or \texttt{wxUSER\_ATTENTION\_ERROR} which results in a more drastic
+action. When in doubt, use the default value.
+
+Note that this function should normally be only used when the application is
+not already in foreground.
+
+This function is currently only implemented for Win32 where it flashes the
+window icon in the taskbar.
+
+
 \membersection{wxTopLevelWindow::SetIcon}\label{wxtoplevelwindowseticon}
 
 \func{void}{SetIcon}{\param{const wxIcon\& }{icon}}
index fab04867f64fc7b3e82c635f2ad05e8330665c01..c4b7e47287a3f48b7c9961049e3db666095eddeb 100644 (file)
@@ -61,6 +61,7 @@ public:
 #ifndef __WXWINCE__
     virtual bool SetShape(const wxRegion& region);
 #endif // __WXWINCE__
+    virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
 
     virtual bool Show(bool show = true);
 
index d7517e5cb3fa03488cbddf81edb097a0ab2b6f96..a193d5edd4a307bbf394df983f5a4d962828ffe2 100644 (file)
@@ -104,6 +104,13 @@ enum
                                wxFULLSCREEN_NOCAPTION
 };
 
+// Styles for RequestUserAttention
+enum
+{
+    wxUSER_ATTENTION_INFO = 1,
+    wxUSER_ATTENTION_ERROR = 2
+};
+
 // ----------------------------------------------------------------------------
 // wxTopLevelWindow: a top level (as opposed to child) window
 // ----------------------------------------------------------------------------
@@ -164,6 +171,11 @@ public:
     // operation is successful.)
     virtual bool SetShape(const wxRegion& WXUNUSED(region)) { return FALSE; }
 
+    // Attracts the users attention to this window if the application is
+    // inactive (should be called when a background event occurs)
+    virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
+
+
     // implementation only from now on
     // -------------------------------
 
index 31639477413a033def899288917ad012f577bee6..11b0b43600e38b9d0cce19f8b6ce96d5765fa101 100644 (file)
@@ -40,6 +40,7 @@
 #endif //WX_PRECOMP
 
 #include "wx/module.h"
+#include "wx/dynlib.h"
 
 #include "wx/msw/private.h"
 #if defined(__WXWINCE__) && !defined(__HANDHELDPC__)
@@ -901,6 +902,50 @@ bool wxTopLevelWindowMSW::SetShape(const wxRegion& region)
 
 #endif // !__WXWINCE__
 
+void wxTopLevelWindowMSW::RequestUserAttention(int flags)
+{
+    // check if we can use FlashWindowEx()
+#ifdef FLASHW_STOP
+    // available in the headers, check if it is supported by the system
+    typedef BOOL (WINAPI *FlashWindowEx_t)(FLASHWINFO *pfwi);
+    FlashWindowEx_t s_pfnFlashWindowEx = NULL;
+    if ( !s_pfnFlashWindowEx )
+    {
+        wxDynamicLibrary dllUser32(_T("user32.dll"));
+        s_pfnFlashWindowEx = (FlashWindowEx_t)
+                                dllUser32.GetSymbol(_T("FlashWindowEx"));
+
+        // we can safely unload user32.dll here, it's goign to remain loaded as
+        // long as the program is running anyhow
+    }
+
+    if ( s_pfnFlashWindowEx )
+    {
+        WinStruct<FLASHWINFO> fwi;
+        fwi.hwnd = GetHwnd();
+        fwi.dwFlags = FLASHW_ALL;
+        if ( flags & wxUSER_ATTENTION_INFO )
+        {
+            // just flash a few times
+            fwi.uCount = 3;
+        }
+        else // wxUSER_ATTENTION_ERROR
+        {
+            // flash until the user notices it
+            fwi.dwFlags |= FLASHW_TIMERNOFG;
+        }
+
+        s_pfnFlashWindowEx(&fwi);
+    }
+    else // FlashWindowEx() not available
+#endif // FLASHW_STOP
+    {
+        wxUnusedVar(flags);
+
+        ::FlashWindow(GetHwnd(), TRUE);
+    }
+}
+
 // ----------------------------------------------------------------------------
 // wxTopLevelWindow event handling
 // ----------------------------------------------------------------------------