
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 0.97 KB | hits: 19 | expires: Never
How to change color of a button label? I.e. get the right text position?
case WM_CTLCOLORSTATIC: {
// check for intended button omitted
INT_PTR br=SendMessage(Wnd,WM_CTLCOLORDLG,wParam,(LPARAM)Wnd);
SetTextColor((HDC)wParam,RGB(255,0,0));
return br;
}break;
case WM_NOTIFY: {
LPNMCUSTOMDRAW n=(LPNMCUSTOMDRAW)lParam;
if (n && n->hdr.code==NM_CUSTOMDRAW
&& n->hdr.idFrom==ID_I_WANT
&& n->dwDrawStage==CDDS_PREPAINT) {
SetTextColor(n->hdc,RGB(255,0,0));
return TRUE;
}
}break;
...
TCHAR s[32];
GetWindowText(n->hdr.hwndFrom,s,32);
DTTOPTS opt;
opt.dwSize=sizeof(opt);
opt.dwFlags=DTT_TEXTCOLOR;
opt.crText=RGB(255,0,0);
DrawThemeTextEx(GetWindowTheme(n->hdr.hwndFrom),n->hdc,BP_CHECKBOX,
CBS_UNCHECKEDNORMAL,s,-1,0,&n->rc,&opt);
SetWindowLong(Wnd,DWL_MSGRESULT,CDRF_SKIPDEFAULT);
...
SIZE sz;
GetThemePartSize(GetWindowTheme(n->hdr.hwndFrom),n->hdc,
BP_CHECKBOX,CBS_UNCHECKEDNORMAL,NULL,TS_DRAW,&sz);