CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Location
    SA
    Posts
    147

    Unhappy Need help with CRichEditCtrl (Please)...

    I have tried everything ... read the MSDN, about this, I have read almost all the articles I could find on setting text bold in a rich edit control ...

    Ok what happens is as follows ....

    CHARFORMAT2 chfFmt;

    m_RichEditCtrl.SetSel(0, 5);

    chfFmt.dwMask = CFM_BOLD;
    chfFmt.dwEffects = CFE_BOLD;

    m_RichEditCtrl.SetSelectionCharFormat(chfFmt);

    <- this will result in

    HERE IS MY TEXT IN MY TEXTBOX

    The first few characters are now bold ...

    Now I try doing this ...


    CHARFORMAT2 chfFmt;

    m_RichEditCtrl.SetSel(0, 5);

    chfFmt.dwMask = 0;
    chfFmt.dwEffects = 0;

    m_RichEditCtrl.SetSelectionCharFormat(chfFmt);

    but the result is that the BOLD text did not return back to normal text it still gives me

    HERE IS MY TEXT IN MY TEXTBOX

    How do I remove bold text, when it was normal, and setting it back to normal, to actually go back to normal, or "unbold" the characters ... ?

    Thanx in advance ...

    xIRC

  2. #2
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Need help with CRichEditCtrl (Please)...

    Originally posted by xIRC
    chfFmt.dwMask = 0;
    chfFmt.dwEffects = 0;
    The problem is here. By setting dwEffects to 0, you tell SetSelectionCharFormat() that you want to remove any styles like bold, italic etc, which is OK. However, by setting dwMask to 0, you say at the same time that you don't intend to influence any of those effects. So in order to set or remove the bold flag in dwEffects, you always have to set dwMask to a value including at least CFM_BOLD.

  3. #3
    Join Date
    Mar 2003
    Location
    SA
    Posts
    147

    Thank you !!!

    Thanks for all your help I've received so far from gstercken ...

    And thank you all as well for also helping me, when I get stuck or someting

    See around ... hehe !

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