How do I change the text color from an edit box on button push? (Win32/C++). I know how to change the text font (i.e. to use in WM_COMMAND, SendMessage() with WM_SETFONT).
On changing text color I think that I need an interaction betweenWM_COMMAND, WM_CTLCOLOREDIT, and SendMessage() but don't know with what kind of parameter . Thank you.
I've figured how to do this on single button. One more question please. If I use the code above for 3 different buttons, it doesn't behave as expected . There is a snippet :
case IDC_BUTTON3: { textFlagRed = textFlagRed; textFlagBlue = !textFlagBlue; textFlagGreen = !textFlagGreen; InvalidateRect(textArea2, NULL, TRUE); break; } case IDC_BUTTON4: { textFlagGreen = textFlagGreen; textFlagBlue = !textFlagBlue; textFlagRed = !textFlagRed; InvalidateRect(textArea2, NULL, TRUE); break; } case IDC_BUTTON5: { textFlagBlue = textFlagBlue; textFlagRed = !textFlagRed; textFlagGreen = !textFlagGreen; InvalidateRect(textArea2, NULL, TRUE); break; } and in WM_CTLCOLORSTATIC
if (textFlagRed && (HWND)lParam == textArea2) { HBRUSH hbr = (HBRUSH) DefWindowProc(hwnd, message, wParam, lParam); SetTextColor((HDC) wParam, RGB(255, 0, 0)); return (BOOL) hbr; } else if (textFlagBlue && (HWND)lParam == textArea2) { HBRUSH hbr = (HBRUSH) DefWindowProc(hwnd, message, wParam, lParam); SetTextColor((HDC) wParam, RGB(0, 0, 255)); return (BOOL) hbr; } else if (textFlagGreen && (HWND)lParam == textArea2) { HBRUSH hbr = (HBRUSH) DefWindowProc(hwnd, message, wParam, lParam); SetTextColor((HDC) wParam, RGB(0, 255, 0)); return (BOOL) hbr; } break; Always is the blue color.