Reputation: 81
Well i able to change the color of Button
create using Createwindow
control using the Custom draw.But button color is still black i want to change this color.Is there any property in CustomDraw
to change the Text color.
Here is my code for background color change
case WM_NOTIFY:
switch (((LPNMHDR)lParam) -> code)
{
case NM_CUSTOMDRAW:
if (((LPNMHDR)lParam) -> idFrom == 10002)
{
LPNMCUSTOMDRAW lpnmCD = (LPNMCUSTOMDRAW)lParam;
switch (lpnmCD -> dwDrawStage)
{
case CDDS_PREPAINT:
SetDCBrushColor(lpnmCD -> hdc, RGB(0, 255, 0));
SetDCPenColor(lpnmCD -> hdc, RGB(0, 255, 0));
SelectObject(lpnmCD -> hdc, GetStockObject(DC_BRUSH));
SelectObject(lpnmCD -> hdc, GetStockObject(DC_PEN));
RoundRect(lpnmCD -> hdc, lpnmCD -> rc.left + 3, lpnmCD -> rc.top + 3,
lpnmCD -> rc.right - 3, lpnmCD -> rc.bottom - 3, 5, 5);
return TRUE;
}
}
}
}
Upvotes: 1
Views: 1348
Reputation: 7620
I think you'll have to draw the text yourself.
Add that code after RoundRect
// Unicode, adapt for ansi
// -----------------------
wchar_t szBtnText[ 32 ] = { 0 };
GetWindowText( ((LPNMHDR)lParam) -> hwndFrom, szBtnText, sizeof(szBtnText) / sizeof(wchar_t) );
SetTextColor(lpnmCD -> hdc, RGB(255, 0, 0));
SetBkMode(lpnmCD -> hdc, TRANSPARENT);
DrawText(lpnmCD -> hdc, szBtnText, wcslen(pszBtnText), &lpnmCD -> rc,
DT_CENTER | DT_SINGLELINE | DT_VCENTER);
return CDRF_SKIPDEFAULT;
Upvotes: 3