Click to See Complete Forum and Search --> : CRichEditCtrl Release Problem


VBCPPGuy
May 5th, 1999, 05:16 PM
Hello,

I am using a Rich Edit control on a dialog to display record information for
a simple record viewer used in a robots.txt generator I am writting in Visual C++ 6. I am
using the RichEdit control so I can make the field names (i.e. Bot Name:) a
different color from the rest of the text. Everything works as intended in
debug builds, but when I compile a release build all the text is black and
not the colors I specify. Here is part of the code I am using:

. . . some code precedes this...
CHARFORMAT cf;
COLORREF crFieldTitles = RGB(0,128,128);
COLORREF crNormalText = GetSysColor(COLOR_WINDOWTEXT);

iSel = m_BotList.GetCurSel();
if(iSel != LB_ERR)
{
iDBIndex = (int)m_BotList.GetItemData(iSel);

m_BotDatabase.GetRecord(iDBIndex);

m_RichBotInfo.GetDefaultCharFormat(cf);

cf.dwEffects = CFE_BOLD|TRUE;

m_RichBotInfo.SetWindowText("");

// Bot Name
cf.crTextColor = crFieldTitles;
m_RichBotInfo.SetWordCharFormat(cf);
m_RichBotInfo.ReplaceSel("Robot Name:");
cf.crTextColor = crNormalText;
m_RichBotInfo.SetWordCharFormat(cf);
m_RichBotInfo.ReplaceSel(" " + m_BotDatabase.m_strBotName);
... code goes on...

Thanks for any help,
Frank R.

VBCPPGuy
May 6th, 1999, 02:06 PM
If anyone has experienced this or knows what is wrong please help. I have posted to three seperate MFC message boards and am not getting any help at all. I have been through the MSDN documentation on the CRichEditCtrl and have tried changing the code some, but the problem persists! I don't know why it would work in Debug, but not Release mode, this stumps me the most.

May 6th, 1999, 10:39 PM
Just a shot in the dark... The fact that it works in Debug mode but not Release mode sounds suspicious.

Try calling AfxInitRichEdit() in your app's InitInstance()

VBCPPGuy
May 7th, 1999, 11:02 AM
I am already calling AfxInitRichEdit() in the init instance of the program. The other features of the RichEdit seam to work, for instance SetBackgroundColor. This is however a dialog based application and the dialog this RichEdit is on is a modal dialog, does that make a difference?

May 9th, 1999, 02:54 PM
The function your using formats only the current word in which the cursor (caret) is located. You need to do a setsel() and then format the selected text with one of the functions that does that.

VBCPPGuy
May 11th, 1999, 03:44 PM
I tried that as well and the text changes color in debug, but not release.