Bold Courier in RichEditControl

I am trying to bold a line of courier text in a CRichEditCntl.  In essence:


It does not change to bold at all.  I also tried wWeight, but that didn't work either.

Any suggestions will be appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
>> In essence:

Please post the real code.  (Often the fictional code to duplicate some bug actually has the bug removed - because one doesn't know where the bug is).
rickhill11Author Commented:
Per your request.  Everything works exactly as I want except that what I call the "Ruler Line" refuses my reasonable requests to print in bold.  See //ruler below

void CParseHotelFileRTFView::CreateOutput(void)
      CRichEditCtrl &pCREC=GetRichEditCtrl();
      PARAFORMAT2 ParaFormat;
      CHARFORMAT2A CharFormat;


      //Get the default format

      //Set default format

      //Set the format for the header
      strcpy(CharFormat.szFaceName,"Times New Roman");
      pCREC.ReplaceSel("Hotel File\n");

      //Make "Disclaimer" slightly larger
      pCREC.ReplaceSel("Disclaimer: ");
      //Make the rest of the disclaimer statement closer to normal size
      pCREC.ReplaceSel("Blah Blah Blah\n\n\n");

      //Print the ruler line, in bold
      pCREC.ReplaceSel("HOTEL                ADDRESS                        PHONE\n\n");

//      pCREC.SetFont(&dfont);
            if(buffer[0]=='*')break;  //no more hotels
rickhill11Author Commented:
So I did some more checking, and I guess that the BOLD is working.  I deliberately set bold for the header, disclaimer, and ruler, and thought that absent a SetCharFormat((), the font would return to the default format which is not bold.
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

AndyAinscowFreelance programmer / ConsultantCommented:
>> the font would return to the default format which is not bold.

The documentation says: Only the attributes specified by the dwMask member of cf are changed by this function.  Which means that nothing is changed as you don't supply any parameters, the font stays as you last set it.
You might want to get the font before you do anything so you can undo any changes at a later time.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rickhill11Author Commented:
I was correct that absent a SetCharFormat(0 statement, the format reverts to the default format.  However, It turns out that GetDefaultCharFormat() doesn't clear/set all the flags.  Somehow a BOLD flag was lurking either from my setting the flag to BOLD in individual statements, or and it not being overwritten when it reverted to default, or it was not set/cleared by GetDefaultFormat().  Either way, I was able to clear the BOLD flag with


This made the default format return to normal.
AndyAinscowFreelance programmer / ConsultantCommented:
>>It turns out that GetDefaultCharFormat() doesn't clear/set all the flags   and   or it was not set/cleared by GetDefaultFormat()
They retrieve values, they do not set/change any flags.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.