문제

when you erase a coloured text. By default, the control sets the new entered text colour back to that was recently erased. how can you avoid that? do you need to check each character style before you type?

UPDATE:

I'm trying to set the text color like this.

SendMessage(hEdit, EM_SETSEL, start_pos, end_pos); //select text for coloring

        CHARFORMAT cf;
        memset( &cf, 0, sizeof cf );
        cf.cbSize = sizeof cf;
        cf.dwMask = CFM_COLOR;
        cf.crTextColor = RGB(255,0,0);
        SendMessage( hEdit , EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);

        SendMessage(hEdit, EM_SETSEL, -1, 0 ); //deselect text
        cf.crTextColor = RGB(0,0,0); //reset colour
        SendMessage( hEdit , EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf); //set colour
도움이 되었습니까?

해결책

Your question is quite unclear. Wild stab at it: you lose all formatting when you assign the Text property. Be sure to use AppendText() instead. And to set the SelectionColor and SelectionBackColor properties back to what it was after colorizing any text so that newly entered text gets the preferred default colors.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top