From 6940f18b48d4360234489967f75e7e89afce228a Mon Sep 17 00:00:00 2001 From: Steve Northover Date: Mon, 25 Aug 2008 19:47:05 +0000 Subject: 244574 - ProgressBar state can be visually lost by updating selection --- .../win32/org/eclipse/swt/widgets/ProgressBar.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'bundles') diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java index f9774ffc54..c7ec93a8df 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java @@ -315,19 +315,26 @@ public void setSelection (int value) { 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; + boolean 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 minumum = /*64*/OS.SendMessage (handle, OS.PBM_GETRANGE, 1, 0); + int selection = (int)/*64*/OS.SendMessage (handle, OS.PBM_GETPOS, 0, 0); + if (selection == 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); } } -- cgit