Can anyone give me a hint(or link to tutorial) how to change color of text inside "edit" control? I'm trying to make sth like IDE (where keywords become blue), so how to change color of substring which is in edit control?
(1) Create a new dialog-based (yourself) mfc program
Add an edit control [ID = IDC_EDIT_DEMO], add a button [ID: IDC_BTN_SETCOLOR,]
2. Response IDC_BTN_SETCOLOR button click event handler
In the previous step before the first in CxxxDlg Add a member variable of type COLORREF [Name: m_clrSel,]
Initialization m_clrSel = RGB (255, 0, 0);
Add the response WM_CTLCOLOR message processing function,
Write the following code
if (IDC_EDIT_DEMO == pWnd-> GetDlgCtrlID ()) / / judgment being drawn is not specified control
{
pDC-> SetTextColor (m_clrSel) ;/ / Set the text color on edit control
return hbr;
}