Piotr Caban : user32: Don' t invalidate ComboBox on LBN_SELCHANGE and LBN_SELCANCEL.
Alexandre Julliard
julliard at winehq.org
Fri Oct 6 14:58:53 CDT 2017
Module: wine
Branch: master
Commit: 9cb29e5182622f7db8316f62fe82e114df73d570
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9cb29e5182622f7db8316f62fe82e114df73d570
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Oct 4 12:38:36 2017 +0200
user32: Don't invalidate ComboBox on LBN_SELCHANGE and LBN_SELCANCEL.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/combo.c | 121 ++++++++++++++++++++++++++--------------------------
1 file changed, 61 insertions(+), 60 deletions(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c
index 4b6bc4f..ee9ce0a 100644
--- a/dlls/user32/combo.c
+++ b/dlls/user32/combo.c
@@ -646,13 +646,58 @@ static void CBPaintButton( LPHEADCOMBO lphc, HDC hdc, RECT rectButton)
}
/***********************************************************************
+ * COMBO_PrepareColors
+ *
+ * This method will sent the appropriate WM_CTLCOLOR message to
+ * prepare and setup the colors for the combo's DC.
+ *
+ * It also returns the brush to use for the background.
+ */
+static HBRUSH COMBO_PrepareColors(
+ LPHEADCOMBO lphc,
+ HDC hDC)
+{
+ HBRUSH hBkgBrush;
+
+ /*
+ * Get the background brush for this control.
+ */
+ if (CB_DISABLED(lphc))
+ {
+ hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLORSTATIC,
+ (WPARAM)hDC, (LPARAM)lphc->self );
+
+ /*
+ * We have to change the text color since WM_CTLCOLORSTATIC will
+ * set it to the "enabled" color. This is the same behavior as the
+ * edit control
+ */
+ SetTextColor(hDC, GetSysColor(COLOR_GRAYTEXT));
+ }
+ else
+ {
+ /* FIXME: In which cases WM_CTLCOLORLISTBOX should be sent? */
+ hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLOREDIT,
+ (WPARAM)hDC, (LPARAM)lphc->self );
+ }
+
+ /*
+ * Catch errors.
+ */
+ if( !hBkgBrush )
+ hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
+
+ return hBkgBrush;
+}
+
+/***********************************************************************
* CBPaintText
*
* Paint CBS_DROPDOWNLIST text field / update edit control contents.
*/
static void CBPaintText(
LPHEADCOMBO lphc,
- HDC hdc)
+ HDC hdc_paint)
{
RECT rectEdit = lphc->textRect;
INT id, size = 0;
@@ -690,14 +735,20 @@ static void CBPaintText(
}
else /* paint text field ourselves */
{
- UINT itemState = ODS_COMBOBOXEDIT;
- HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0;
+ HDC hdc = hdc_paint ? hdc_paint : GetDC(lphc->self);
+ UINT itemState = ODS_COMBOBOXEDIT;
+ HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0;
+ HBRUSH hPrevBrush, hBkgBrush;
/*
* Give ourselves some space.
*/
InflateRect( &rectEdit, -1, -1 );
+ hBkgBrush = COMBO_PrepareColors( lphc, hdc );
+ hPrevBrush = SelectObject( hdc, hBkgBrush );
+ FillRect( hdc, &rectEdit, hBkgBrush );
+
if( CB_OWNERDRAWN(lphc) )
{
DRAWITEMSTRUCT dis;
@@ -757,6 +808,12 @@ static void CBPaintText(
if( hPrevFont )
SelectObject(hdc, hPrevFont );
+
+ if( hPrevBrush )
+ SelectObject( hdc, hPrevBrush );
+
+ if( !hdc_paint )
+ ReleaseDC( lphc->self, hdc );
}
HeapFree( GetProcessHeap(), 0, pText );
}
@@ -787,52 +844,6 @@ static void CBPaintBorder(
}
/***********************************************************************
- * COMBO_PrepareColors
- *
- * This method will sent the appropriate WM_CTLCOLOR message to
- * prepare and setup the colors for the combo's DC.
- *
- * It also returns the brush to use for the background.
- */
-static HBRUSH COMBO_PrepareColors(
- LPHEADCOMBO lphc,
- HDC hDC)
-{
- HBRUSH hBkgBrush;
-
- /*
- * Get the background brush for this control.
- */
- if (CB_DISABLED(lphc))
- {
- hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLORSTATIC,
- (WPARAM)hDC, (LPARAM)lphc->self );
-
- /*
- * We have to change the text color since WM_CTLCOLORSTATIC will
- * set it to the "enabled" color. This is the same behavior as the
- * edit control
- */
- SetTextColor(hDC, GetSysColor(COLOR_GRAYTEXT));
- }
- else
- {
- /* FIXME: In which cases WM_CTLCOLORLISTBOX should be sent? */
- hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLOREDIT,
- (WPARAM)hDC, (LPARAM)lphc->self );
- }
-
- /*
- * Catch errors.
- */
- if( !hBkgBrush )
- hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
-
- return hBkgBrush;
-}
-
-
-/***********************************************************************
* COMBO_Paint
*/
static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC)
@@ -1285,18 +1296,8 @@ static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd )
if( HIWORD(wParam) == LBN_SELCHANGE)
{
if( lphc->wState & CBF_EDIT )
- {
- INT index = SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
lphc->wState |= CBF_NOLBSELECT;
- CBUpdateEdit( lphc, index );
- /* select text in edit, as Windows does */
- SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1);
- }
- else
- {
- InvalidateRect(lphc->self, &lphc->textRect, TRUE);
- UpdateWindow(lphc->self);
- }
+ CBPaintText( lphc, NULL );
}
break;
More information about the wine-cvs
mailing list