Как изменить цвет в поле EDIT?
За основу взят код с MSDN
Код:
case WM_COMMAND:
if ((LOWORD(wParam)==106)&&(HIWORD(wParam)==0))
{
HDC hdc;
CHOOSEFONT cf;
static LOGFONT lf;
static DWORD rgbCurrent;
HFONT hfont,hfontPrev;
COLORREF rgbPrev;
ZeroMemory(&cf, sizeof(cf));
cf.lStructSize=sizeof(cf);
cf.hwndOwner=hwnd1;
cf.lpLogFont=&lf;
cf.rgbColors=rgbCurrent;
cf.Flags=CF_EFFECTS|CF_SCREENFONTS;//|CF_INITTOLOGFONTSTRUCT;
if(ChooseFont(&cf)==TRUE)
{
//hdc=GetDC(hwnd1);
hfont = CreateFontIndirect(cf.lpLogFont);
hfontPrev = (HFONT)SelectObject(hdc, hfont);
rgbCurrent= cf.rgbColors;
rgbPrev = SetTextColor(hdc, rgbCurrent);
//ReleaseDC(hwnd1,hdc);
SendMessage(hwnd1,WM_SETFONT,(WPARAM) hfont,TRUE);
}
}
break;
if ((LOWORD(wParam)==106)&&(HIWORD(wParam)==0))
{
HDC hdc;
CHOOSEFONT cf;
static LOGFONT lf;
static DWORD rgbCurrent;
HFONT hfont,hfontPrev;
COLORREF rgbPrev;
ZeroMemory(&cf, sizeof(cf));
cf.lStructSize=sizeof(cf);
cf.hwndOwner=hwnd1;
cf.lpLogFont=&lf;
cf.rgbColors=rgbCurrent;
cf.Flags=CF_EFFECTS|CF_SCREENFONTS;//|CF_INITTOLOGFONTSTRUCT;
if(ChooseFont(&cf)==TRUE)
{
//hdc=GetDC(hwnd1);
hfont = CreateFontIndirect(cf.lpLogFont);
hfontPrev = (HFONT)SelectObject(hdc, hfont);
rgbCurrent= cf.rgbColors;
rgbPrev = SetTextColor(hdc, rgbCurrent);
//ReleaseDC(hwnd1,hdc);
SendMessage(hwnd1,WM_SETFONT,(WPARAM) hfont,TRUE);
}
}
break;
The SetTextColor function sets the text color for the specified device context to the specified color.