From 9aef482062e98afeee0662d0510a4011d90973c6 Mon Sep 17 00:00:00 2001 From: Steve Northover Date: Mon, 11 Jul 2005 18:43:09 +0000 Subject: 103349 - Scale widget switches focus when setting background --- .../win32/org/eclipse/swt/widgets/Slider.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets') diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java index 412d6d1bf0..5baca8e244 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java @@ -66,6 +66,7 @@ import org.eclipse.swt.events.*; */ public class Slider extends Control { int increment, pageIncrement; + boolean ignoreFocus; static final int ScrollBarProc; static final TCHAR ScrollBarClass = new TCHAR (0, "SCROLLBAR", true); static { @@ -371,11 +372,13 @@ void setBounds (int x, int y, int width, int height, int flags) { /* * Bug in Windows. If the scroll bar is resized when it has focus, * the flashing cursor that is used to show that the scroll bar has - * focus is not moved. The fix is to post a fake WM_SETFOCUS to + * focus is not moved. The fix is to send a fake WM_SETFOCUS to * get the scroll bar to recompute the size of the flashing cursor. */ if (OS.GetFocus () == handle) { - OS.PostMessage (handle, OS.WM_SETFOCUS, 0, 0); + ignoreFocus = true; + OS.SendMessage (handle, OS.WM_SETFOCUS, 0, 0); + ignoreFocus = false; } } @@ -488,12 +491,14 @@ boolean SetScrollInfo (int hwnd, int flags, SCROLLINFO info, boolean fRedraw) { /* * Bug in Windows. If the thumb is resized when it has focus, * the flashing cursor that is used to show that the scroll bar - * has focus is not moved. The fix is to post a fake WM_SETFOCUS + * has focus is not moved. The fix is to send a fake WM_SETFOCUS * to get the scroll bar to recompute the size of the flashing * cursor. */ if (OS.GetFocus () == handle) { - OS.PostMessage (handle, OS.WM_SETFOCUS, 0, 0); + ignoreFocus = true; + OS.SendMessage (handle, OS.WM_SETFOCUS, 0, 0); + ignoreFocus = false; } return result; } @@ -703,6 +708,11 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { return result; } +LRESULT WM_SETFOCUS (int wParam, int lParam) { + if (ignoreFocus) return null; + return super.WM_SETFOCUS (wParam, lParam); +} + LRESULT wmScrollChild (int wParam, int lParam) { /* Do nothing when scrolling is ending */ -- cgit