* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
- * NOTES
- *
- * This code was audited for completeness against the documented features
- * of Comctl32.dll version 6.0 on Oct. 4, 2004, by Dimitrie O. Paun.
- *
- * Unless otherwise noted, we believe this code to be complete, as per
- * the specification mentioned above.
- * If you discover missing features, or bugs, please note them below.
- *
* TODO:
- * - ComboBox_[GS]etMinVisible()
- * - CB_GETMINVISIBLE, CB_SETMINVISIBLE
* - CB_SETTOPINDEX
*/
DrawFrameControl(hdc, &rectButton, DFC_SCROLL, buttonState);
}
+/***********************************************************************
+ * 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))
+ {
+#ifdef __REACTOS__
+ hBkgBrush = GetControlColor(lphc->owner, lphc->self, hDC, WM_CTLCOLORSTATIC);
+#else
+ hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLORSTATIC,
+ (WPARAM)hDC, (LPARAM)lphc->self );
+#endif
+ /*
+ * 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? */
+#ifdef __REACTOS__
+ hBkgBrush = GetControlColor(lphc->owner, lphc->self, hDC, WM_CTLCOLOREDIT);
+#else
+ hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLOREDIT,
+ (WPARAM)hDC, (LPARAM)lphc->self );
+#endif
+ }
+
+ /*
+ * Catch errors.
+ */
+ if( !hBkgBrush )
+ hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
+
+ return hBkgBrush;
+}
+
/***********************************************************************
* CBPaintText
*
*/
static void CBPaintText(
LPHEADCOMBO lphc,
- HDC hdc,
- RECT rectEdit)
+ HDC hdc_paint)
{
+ RECT rectEdit = lphc->textRect;
INT id, size = 0;
LPWSTR pText = NULL;
- if( lphc->wState & CBF_NOREDRAW ) return;
-
TRACE("\n");
/* follow Windows combobox that sends a bunch of text
pText[size] = '\0'; /* just in case */
} else return;
}
- else
- if( !CB_OWNERDRAWN(lphc) )
- return;
if( lphc->wState & CBF_EDIT )
{
static const WCHAR empty_stringW[] = { 0 };
if( CB_HASSTRINGS(lphc) ) SetWindowTextW( lphc->hWndEdit, pText ? pText : empty_stringW );
if( lphc->wState & CBF_FOCUSED )
- SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1));
+ SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, MAXLONG);
}
- else /* paint text field ourselves */
+ else if(!(lphc->wState & CBF_NOREDRAW) && IsWindowVisible( lphc->self ))
{
- UINT itemState = ODS_COMBOBOXEDIT;
- HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0;
+ /* paint text field ourselves */
+ 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;
if( hPrevFont )
SelectObject(hdc, hPrevFont );
+
+ if( hPrevBrush )
+ SelectObject( hdc, hPrevBrush );
+
+ if( !hdc_paint )
+ ReleaseDC( lphc->self, hdc );
}
#ifdef __REACTOS__
if (pText)
DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT);
}
-/***********************************************************************
- * 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))
- {
-#ifdef __REACTOS__
- hBkgBrush = GetControlColor(lphc->owner, lphc->self, hDC, WM_CTLCOLORSTATIC);
-#else
- hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLORSTATIC,
- (WPARAM)hDC, (LPARAM)lphc->self );
-#endif
- /*
- * 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? */
-#ifdef __REACTOS__
- hBkgBrush = GetControlColor(lphc->owner, lphc->self, hDC, WM_CTLCOLOREDIT);
-#else
- hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLOREDIT,
- (WPARAM)hDC, (LPARAM)lphc->self );
-#endif
- }
-
- /*
- * Catch errors.
- */
- if( !hBkgBrush )
- hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
-
- return hBkgBrush;
-}
-
-
/***********************************************************************
* COMBO_Paint
*/
}
if( !(lphc->wState & CBF_EDIT) )
- CBPaintText( lphc, hDC, lphc->textRect);
+ CBPaintText( lphc, hDC );
if( hPrevBrush )
SelectObject( hDC, hPrevBrush );
if (nHeight < nDroppedHeight - COMBO_YBORDERSIZE())
nDroppedHeight = nHeight + COMBO_YBORDERSIZE();
-
- if (nDroppedHeight < nHeight)
- {
- if (nItems < 5)
- nDroppedHeight = (nItems+1)*nIHeight;
- else if (nDroppedHeight < 6*nIHeight)
- nDroppedHeight = 6*nIHeight;
- }
}
r.left = rect.left;
&lphc->buttonRect,
&lphc->droppedRect);
- CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
+ CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, FALSE );
}
SendMessageW(lphc->hWndLBox, LB_SETTOPINDEX, wParam, 0);
/* no LBN_SELCHANGE in this case, update manually */
- if( lphc->wState & CBF_EDIT )
- CBUpdateEdit( lphc, (INT)wParam );
- else
- InvalidateRect(lphc->self, &lphc->textRect, TRUE);
+ CBPaintText( lphc, NULL );
lphc->wState &= ~CBF_SELCHANGE;
return lParam;
case CB_GETLBTEXT: