]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxSHUTDOWN_LOGOFF flag, don't use EWX_FORCE by default but only if wxSHUTDOWN_F...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Aug 2008 10:56:05 +0000 (10:56 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Aug 2008 10:56:05 +0000 (10:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/utils.h
interface/wx/utils.h
src/msw/utils.cpp

index 7e9a195160cc5184d2453e4230619925a97a5c03..72004ffe134c12660833d23f14f6f99eeb2a9b99 100644 (file)
@@ -419,12 +419,14 @@ enum wxKillFlags
 
 enum wxShutdownFlags
 {
-    wxSHUTDOWN_POWEROFF,    // power off the computer
-    wxSHUTDOWN_REBOOT       // shutdown and reboot
+    wxSHUTDOWN_FORCE    = 1,// can be combined with other flags (MSW-only)
+    wxSHUTDOWN_POWEROFF = 2,// power off the computer
+    wxSHUTDOWN_REBOOT   = 4,// shutdown and reboot
+    wxSHUTDOWN_LOGOFF   = 8 // close session (currently MSW-only)
 };
 
 // Shutdown or reboot the PC
-WXDLLIMPEXP_BASE bool wxShutdown(wxShutdownFlags wFlags);
+WXDLLIMPEXP_BASE bool wxShutdown(int flags = wxSHUTDOWN_POWEROFF);
 
 // send the given signal to the process (only NONE and KILL are supported under
 // Windows, all others mean TERM), return 0 if ok and -1 on error
index 2e49aaf7bd8d4af6c11a696caa1767c2ffc80d90..d4b6d21b787e9ec00545595e2f6d0c333a451eab 100644 (file)
@@ -959,18 +959,22 @@ bool wxShell(const wxString& command = NULL);
     This function shuts down or reboots the computer depending on the value of
     the @a flags.
 
-    @note Doing this requires the corresponding access rights (superuser under
-          Unix, SE_SHUTDOWN privilege under Windows NT) and that this function
-          is only implemented under Unix and Win32.
+    @note Note that performing the shutdown requires the corresponding access
+        rights (superuser under Unix, SE_SHUTDOWN privilege under Windows NT)
+        and that this function is only implemented under Unix and MSW.
 
     @param flags
-        Either wxSHUTDOWN_POWEROFF or wxSHUTDOWN_REBOOT
+        One of @c wxSHUTDOWN_POWEROFF, @c wxSHUTDOWN_REBOOT or
+        @c wxSHUTDOWN_LOGOFF (currently implemented only for MSW) possibly
+        combined with @c wxSHUTDOWN_FORCE which forces shutdown under MSW by
+        forcefully terminating all the applications. As doing this can result
+        in a data loss, this flag shouldn't be used unless really necessary.
 
     @return @true on success, @false if an error occurred.
 
     @header{wx/utils.h}
 */
-bool wxShutdown(wxShutdownFlags flags);
+bool wxShutdown(int flags = wxSHUTDOWN_POWEROFF);
 
 //@}
 
index ed2e0d224d806e218be693967aba928fb8be048b..612ced86ae80fe880c61817017b9326e1bfed051 100644 (file)
@@ -953,7 +953,7 @@ bool wxShell(const wxString& command)
 }
 
 // Shutdown or reboot the PC
-bool wxShutdown(wxShutdownFlags WXUNUSED_IN_WINCE(wFlags))
+bool wxShutdown(int WXUNUSED_IN_WINCE(flags))
 {
 #ifdef __WXWINCE__
     // TODO-CE
@@ -990,15 +990,25 @@ bool wxShutdown(wxShutdownFlags WXUNUSED_IN_WINCE(wFlags))
 
     if ( bOK )
     {
-        UINT flags = EWX_SHUTDOWN | EWX_FORCE;
-        switch ( wFlags )
+        UINT wFlags = 0;
+        if ( flags & wxSHUTDOWN_FORCE )
+        {
+            wFlags = EWX_FORCE;
+            flags &= ~wxSHUTDOWN_FORCE;
+        }
+
+        switch ( flags )
         {
             case wxSHUTDOWN_POWEROFF:
-                flags |= EWX_POWEROFF;
+                wFlags |= EWX_POWEROFF;
                 break;
 
             case wxSHUTDOWN_REBOOT:
-                flags |= EWX_REBOOT;
+                wFlags |= EWX_REBOOT;
+                break;
+
+            case wxSHUTDOWN_LOGOFF:
+                wFlags |= EWX_LOGOFF;
                 break;
 
             default:
@@ -1006,11 +1016,11 @@ bool wxShutdown(wxShutdownFlags WXUNUSED_IN_WINCE(wFlags))
                 return false;
         }
 
-        bOK = ::ExitWindowsEx(flags, 0) != 0;
+        bOK = ::ExitWindowsEx(wFlags, 0) != 0;
     }
 
     return bOK;
-#endif // Win32/16
+#endif // WinCE/!WinCE
 }
 
 // ----------------------------------------------------------------------------