CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 1999
    Posts
    4

    CRichEditCtrl Release Problem

    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.



  2. #2
    Join Date
    May 1999
    Posts
    4

    Re: CRichEditCtrl Release Problem

    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.


  3. #3
    Guest

    Re: CRichEditCtrl Release Problem

    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()


  4. #4
    Join Date
    May 1999
    Posts
    4

    Re: CRichEditCtrl Release Problem

    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?


  5. #5
    Guest

    Re: CRichEditCtrl Release Problem

    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.



  6. #6
    Join Date
    May 1999
    Posts
    4

    Re: CRichEditCtrl Release Problem

    I tried that as well and the text changes color in debug, but not release.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured