diff dwt/widgets/ProgressBar.d @ 320:da968414c383

Merge changes SWT 3.4.1
author Frank Benoit <benoit@tionex.de>
date Mon, 03 Nov 2008 21:58:40 +0100
parents fd9c62a2998e
children
line wrap: on
line diff
--- a/dwt/widgets/ProgressBar.d	Thu Oct 23 23:41:09 2008 +0200
+++ b/dwt/widgets/ProgressBar.d	Mon Nov 03 21:58:40 2008 +0100
@@ -340,19 +340,26 @@
     checkWidget ();
     /*
     * Feature in Vista.  When the progress bar is not in
-    * a normal state, PBM_SETPOS does not set the position.
+    * a normal state, PBM_SETPOS does not set the position
+    * of the bar when the selection is equal to the minimum.
     * This is undocumented.  The fix is to temporarily
     * set the state to PBST_NORMAL, set the position, then
     * reset the state.
     */
     int /*long*/ state = 0;
+    bool fixSelection = false;
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
-        state = OS.SendMessage (handle, OS.PBM_GETSTATE, 0, 0);
-        OS.SendMessage (handle, OS.PBM_SETSTATE, OS.PBST_NORMAL, 0);
+        int /*long*/ minumum = OS.SendMessage (handle, OS.PBM_GETRANGE, 1, 0);
+        int /*long*/ selection = OS.SendMessage (handle, OS.PBM_GETPOS, 0, 0);
+        if (selection is minumum) {
+            fixSelection = true;
+            state = OS.SendMessage (handle, OS.PBM_GETSTATE, 0, 0);
+            OS.SendMessage (handle, OS.PBM_SETSTATE, OS.PBST_NORMAL, 0);
+        }
     }
     OS.SendMessage (handle, OS.PBM_SETPOS, value, 0);
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
-        OS.SendMessage (handle, OS.PBM_SETSTATE, state, 0);
+        if (fixSelection) OS.SendMessage (handle, OS.PBM_SETSTATE, state, 0);
     }
 }