Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionfreopen and textbox data Pin
Cpaulv23-Oct-06 19:20
Cpaulv23-Oct-06 19:20 
AnswerRe: freopen and textbox data Pin
Waldermort23-Oct-06 19:32
Waldermort23-Oct-06 19:32 
GeneralRe: freopen and textbox data Pin
Cpaulv24-Oct-06 3:20
Cpaulv24-Oct-06 3:20 
QuestionCFileFind in Temporary Internet Files Pin
locoone23-Oct-06 14:02
locoone23-Oct-06 14:02 
AnswerRe: CFileFind in Temporary Internet Files Pin
tanvon malik23-Oct-06 19:14
tanvon malik23-Oct-06 19:14 
GeneralRe: CFileFind in Temporary Internet Files Pin
locoone24-Oct-06 15:07
locoone24-Oct-06 15:07 
AnswerRe: CFileFind in Temporary Internet Files Pin
Mila02523-Oct-06 20:41
Mila02523-Oct-06 20:41 
QuestionHow to set text color in CRichEditCtrl? Pin
David.YueZuo23-Oct-06 13:57
David.YueZuo23-Oct-06 13:57 
Hi all,
Who can help me for my below question? I will appriciate that.

In my MFC project, I used RichEdit replacing RichEdit2, but the color of the text are shifted one unit.
My code:

CString strings[3] = {_T("Apple"), _T("Orange"), _T("Pear")};
for (int i = 0; i < 3; i ++)
{
CHARFORMAT2 cf;
m_richEditCtrl.GetSelectionCharFormat(cf);
if ( i % 2 == 0 )
{
cf.crTextColor = (DWORD) RGB(255, 0 , 0); // Red color
}
else
{
cf.crTextColor = (DWORD) RGB(0, 0, 225); // Blue color
}
cf.dwEffects = static_cast<dword>(~CFE_AUTOCOLOR);
cf.dwMask = CFM_COLOR;

long length = m_richEditCtrl.GetTextLength();
m_richEditCtrl.SetSel(length, -1);
m_richEditCtrl.ReplaceSel(strings[i]);

long newLength = m_richEditCtrl.GetTextLength();
m_richEditCtrl.SetSel(length, newLength );
m_richEditCtrl.SetSelectionCharFormat(cf);
}

When I used RichEdit1 the program works perfect, but after I used RichEdit2 the color of text shows weird.
Accordding to the code, "Apple" should show red color, "Orange" should show blue color, "Pear" should show red color again. However, the actual text color are: letters "Apple" are red, "O" is red too, "range pe" are blue , and "ar" are red. That doesn't make any sense....Confused | :confused:

Is there anyone can help me on that? Smile | :)

Thanks!

David Zuo

AnswerRe: How to set text color in CRichEditCtrl? Pin
Mark Salsbery23-Oct-06 14:07
Mark Salsbery23-Oct-06 14:07 
GeneralRe: How to set text color in CRichEditCtrl? Pin
David.YueZuo24-Oct-06 11:55
David.YueZuo24-Oct-06 11:55 
GeneralRe: How to set text color in CRichEditCtrl? Pin
Mark Salsbery24-Oct-06 12:30
Mark Salsbery24-Oct-06 12:30 
GeneralRe: How to set text color in CRichEditCtrl? Pin
David.YueZuo24-Oct-06 13:28
David.YueZuo24-Oct-06 13:28 
QuestionLoading a Dialog resource into another form Dynamically Pin
bobm523-Oct-06 13:35
bobm523-Oct-06 13:35 
AnswerRe: Loading a Dialog resource into another form Dynamically Pin
Mark Salsbery23-Oct-06 13:50
Mark Salsbery23-Oct-06 13:50 
AnswerRe: Loading a Dialog resource into another form Dynamically Pin
Hamid_RT25-Oct-06 19:40
Hamid_RT25-Oct-06 19:40 
Questiondrag and drop into a webbrowser activex control Pin
derek_23-Oct-06 13:22
derek_23-Oct-06 13:22 
Questionsocket connection Pin
nahitan23-Oct-06 13:11
nahitan23-Oct-06 13:11 
AnswerRe: socket connection Pin
Mark Salsbery23-Oct-06 13:38
Mark Salsbery23-Oct-06 13:38 
GeneralRe: socket connection Pin
nahitan23-Oct-06 13:46
nahitan23-Oct-06 13:46 
GeneralRe: socket connection Pin
Mark Salsbery23-Oct-06 13:57
Mark Salsbery23-Oct-06 13:57 
AnswerRe: socket connection Pin
fat_boy23-Oct-06 23:42
fat_boy23-Oct-06 23:42 
AnswerRe: socket connection Pin
Moak1-Nov-06 3:15
Moak1-Nov-06 3:15 
QuestionMouseWheel Question Pin
Mark F.23-Oct-06 12:33
Mark F.23-Oct-06 12:33 
AnswerRe: MouseWheel Question Pin
Mark Salsbery23-Oct-06 13:16
Mark Salsbery23-Oct-06 13:16 
GeneralRe: MouseWheel Question [fixed] Pin
Mark F.23-Oct-06 15:02
Mark F.23-Oct-06 15:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.