From bd8ccaacc9ef017cabd38ca03e944f5594cda26c Mon Sep 17 00:00:00 2001 From: Steve Northover Date: Wed, 20 Jul 2005 20:28:28 +0000 Subject: XP Tabfolder theme code flashes too much when resized --- .../win32/org/eclipse/swt/widgets/Button.java | 20 ---------------- .../win32/org/eclipse/swt/widgets/Control.java | 10 ++++---- .../win32/org/eclipse/swt/widgets/Group.java | 27 ++++++++++++++++++++++ .../win32/org/eclipse/swt/widgets/Label.java | 22 ++++++++++++++++++ .../win32/org/eclipse/swt/widgets/Scale.java | 19 --------------- 5 files changed, 53 insertions(+), 45 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index 426aebb481..7c79d02540 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -880,26 +880,6 @@ LRESULT wmCommandChild (int wParam, int lParam) { return super.wmCommandChild (wParam, lParam); } -LRESULT wmColorChild (int wParam, int lParam) { - LRESULT result = super.wmColorChild (wParam, lParam); - /* - * Feature in Windows. When WM_CTLCOLORBTN returns - * a NULL brush to indicate that the background should - * not be drawn, when the button has the BS_RADIOBUTTON - * style, it draws black. The fix is to draw the background - * in WM_CTLCOLORBTN. - */ - if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { - Control control = findThemeControl (); - if (control != null) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - control.drawThemeBackground (wParam, handle, rect); - } - } - return result; -} - LRESULT wmDrawChild (int wParam, int lParam) { if ((style & SWT.ARROW) == 0) return super.wmDrawChild (wParam, lParam); DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java index fc011c9e81..46e8c17ce5 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java @@ -3216,12 +3216,7 @@ LRESULT WM_ERASEBKGND (int wParam, int lParam) { if ((state & TRANSPARENT) != 0) { if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { Control control = findThemeControl (); - if (control != null) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - control.drawThemeBackground (wParam, handle, rect); - return LRESULT.ONE; - } + if (control != null) return LRESULT.ONE; } } return null; @@ -3873,6 +3868,9 @@ LRESULT wmColorChild (int wParam, int lParam) { OS.SetTextColor (wParam, forePixel); OS.SetBkColor (wParam, backPixel); if (control != null) { + RECT rect = new RECT (); + OS.GetClientRect (handle, rect); + control.drawThemeBackground (wParam, handle, rect); OS.SetBkMode (wParam, OS.TRANSPARENT); return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH)); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java index aa6aa182e4..00a5969570 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java @@ -370,4 +370,31 @@ LRESULT WM_SIZE (int wParam, int lParam) { return result; } +LRESULT WM_UPDATEUISTATE (int wParam, int lParam) { + LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam); + if (result != null) return result; + /* + * Feature in Windows. When WM_UPDATEUISTATE is sent to + * a group, it sends WM_CTLCOLORBTNto get the foreground + * and background. If drawing happens in WM_CTLCOLORBTN, + * it will overwrite the contents of the control. The + * fix is draw the group without drawing the background + * and avoid the group window proc. + * + * NOTE: The DefWindowProc() must be called in order to + * broadcast WM_UPDATEUISTATE message to the children. + * + */ + if ((state & TRANSPARENT) != 0) { + if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { + Control control = findThemeControl (); + if (control != null) { + OS.InvalidateRect (handle, null, false); + int code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam); + return new LRESULT (code); + } + } + } + return result; +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java index 01c3cb26b7..3fb0eb85ae 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java @@ -429,6 +429,28 @@ LRESULT WM_SIZE (int wParam, int lParam) { return result; } +LRESULT WM_UPDATEUISTATE (int wParam, int lParam) { + LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam); + /* + * Feature in Windows. When WM_UPDATEUISTATE is sent to + * a static control, it sends WM_CTLCOLORSTATIC to get the + * foreground and background. If any drawing happens in + * WM_CTLCOLORBTN, it overwrites the contents of the control. + * The fix is draw the static without drawing the background + * and avoid the group window proc. + */ + if ((state & TRANSPARENT) != 0) { + if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { + Control control = findThemeControl (); + if (control != null) { + OS.InvalidateRect (handle, null, false); + return LRESULT.ZERO; + } + } + } + return result; +} + LRESULT wmDrawChild (int wParam, int lParam) { DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT (); OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java index 6ba233cccf..498dbada6b 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java @@ -436,25 +436,6 @@ LRESULT WM_SIZE (int wParam, int lParam) { return super.WM_SIZE (wParam, lParam); } -LRESULT wmColorChild (int wParam, int lParam) { - LRESULT result = super.wmColorChild (wParam, lParam); - /* - * Feature in Windows. When WM_CTLCOLORSTATIC returns - * a NULL brush to indicate that the background should - * not be drawn, the scale draws using a black background. - * The fix is to draw the background in WM_CTLCOLORSTATIC. - */ - if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { - Control control = findThemeControl (); - if (control != null) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - control.drawThemeBackground (wParam, handle, rect); - } - } - return result; -} - LRESULT wmScrollChild (int wParam, int lParam) { /* Do nothing when scrolling is ending */ -- cgit