Commit 1d2bdf5a authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

- Implement WM_ENABLE handler to update cached control style when the

control is disabled. - Move background drawing into WM_ERASEBKGND handler and draw the background differently when disabled. - Change WM_PAINT handler to draw text with transparent background and with the correct colour for the style. - Initialize selected field to -1 instead of 0 so that the control notices when field 0 is selected.
parent 99fda0a1
......@@ -490,19 +490,16 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc)
RECT *rcClient = &infoPtr->rcClient;
RECT *calbutton = &infoPtr->calbutton;
RECT *checkbox = &infoPtr->checkbox;
HBRUSH hbr;
SIZE size;
COLORREF oldBk, oldTextColor;
COLORREF oldTextColor;
/* draw control edge */
TRACE("\n");
hbr = CreateSolidBrush(RGB(255, 255, 255));
FillRect(hdc, rcClient, hbr);
DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT);
DeleteObject(hbr);
if (infoPtr->dateValid) {
HFONT oldFont = SelectObject (hdc, infoPtr->hFont);
INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
WCHAR txt[80];
DATETIME_ReturnTxt (infoPtr, 0, txt, sizeof(txt)/sizeof(txt[0]));
......@@ -521,18 +518,23 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc)
field->bottom = rcDraw->bottom;
prevright = field->right;
if ((infoPtr->haveFocus) && (i == infoPtr->select)) {
hbr = CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION));
if (infoPtr->dwStyle & WS_DISABLED)
oldTextColor = SetTextColor (hdc, comctl32_color.clrGrayText);
else if ((infoPtr->haveFocus) && (i == infoPtr->select)) {
/* fill if focussed */
HBRUSH hbr = CreateSolidBrush (comctl32_color.clrActiveCaption);
FillRect(hdc, field, hbr);
oldBk = SetBkColor (hdc, GetSysColor(COLOR_ACTIVECAPTION));
oldTextColor = SetTextColor (hdc, GetSysColor(COLOR_WINDOW));
DeleteObject (hbr);
oldTextColor = SetTextColor (hdc, comctl32_color.clrWindow);
}
else
oldTextColor = SetTextColor (hdc, comctl32_color.clrWindowText);
/* draw the date text using the colour set above */
DrawTextW (hdc, txt, strlenW(txt), field, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
SetBkColor (hdc, oldBk);
SetTextColor (hdc, oldTextColor);
} else
DrawTextW ( hdc, txt, strlenW(txt), field, DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
}
SetBkMode (hdc, oldBkMode);
SelectObject (hdc, oldFont);
}
......@@ -611,7 +613,7 @@ DATETIME_LButtonDown (DATETIME_INFO *infoPtr, WORD wKey, INT x, INT y)
DATETIME_SendSimpleNotify (infoPtr, DTN_DROPDOWN);
}
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
return 0;
}
......@@ -668,6 +670,45 @@ DATETIME_Command (DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
static LRESULT
DATETIME_Enable (DATETIME_INFO *infoPtr, BOOL bEnable)
{
TRACE("%p %s\n", infoPtr, bEnable ? "TRUE" : "FALSE");
if (bEnable)
infoPtr->dwStyle &= ~WS_DISABLED;
else
infoPtr->dwStyle |= WS_DISABLED;
return 0;
}
static LRESULT
DATETIME_EraseBackground (DATETIME_INFO *infoPtr, HDC hdc)
{
HBRUSH hBrush, hSolidBrush = NULL;
RECT rc;
if (infoPtr->dwStyle & WS_DISABLED)
hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrBtnFace);
else
{
hBrush = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLOREDIT,
(WPARAM)hdc, (LPARAM)infoPtr->hwndSelf);
if (!hBrush)
hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrWindow);
}
GetClientRect (infoPtr->hwndSelf, &rc);
FillRect (hdc, &rc, hBrush);
if (hSolidBrush)
DeleteObject(hSolidBrush);
return -1;
}
static LRESULT
DATETIME_Notify (DATETIME_INFO *infoPtr, int idCtrl, LPNMHDR lpnmh)
{
TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom);
......@@ -904,6 +945,7 @@ DATETIME_Create (HWND hwnd, LPCREATESTRUCTW lpcs)
infoPtr->fieldRect = (RECT *) Alloc (infoPtr->nrFieldsAllocated * sizeof(RECT));
infoPtr->buflen = (int *) Alloc (infoPtr->nrFieldsAllocated * sizeof(int));
infoPtr->hwndNotify = lpcs->hwndParent;
infoPtr->select = -1; /* initially, nothing is selected */
DATETIME_StyleChanged(infoPtr, GWL_STYLE, &ss);
DATETIME_SetFormatW (infoPtr, 0);
......@@ -989,6 +1031,12 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_NOTIFY:
return DATETIME_Notify (infoPtr, (int)wParam, (LPNMHDR)lParam);
case WM_ENABLE:
return DATETIME_Enable (infoPtr, (BOOL)wParam);
case WM_ERASEBKGND:
return DATETIME_EraseBackground (infoPtr, (HDC)wParam);
case WM_GETDLGCODE:
return DLGC_WANTARROWS | DLGC_WANTCHARS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment