3

In my app, pressing a button activates a dialog box. This dialog box contains a rich edit control 2.0. I want to set the background color of this rich edit control 2.0 to red on its creation,i.e, the default background color of this rich edit control should be red (instead of white, which is the actual default). I'm thinking of using SetBackgroundColor() function to set the color, but I want to know where to place the code so that it is executed when the rich edit control 2.0 is created.

Thanks

molu
  • 77
  • 1
  • 11

1 Answers1

1

Can't do it when it is created. You have to do it after it is created. If the control is in a dialog box, generally, you will do it this way:

1) Override DoDataExchange() in your dialog box class and put an entry for DDX_Control(pDX, IDC_RICHEDI1, m_richedit) -- substitute proper id's and variable names

2) Override OnInitDialog() in your dialog box. Using m_richedit (or whatever you name it), set the background color with SetBackgroundColor. It may not do what you want and may have to look into SetDefaultCharFormat, SetParaFormat, or SetSelectionCharFormat.

Joseph Willcoxson
  • 5,853
  • 1
  • 15
  • 29
  • Thanks! I used the OnInitDialog() function to get the job done. So there is no OnInit() equivalent for a richedit control box? – molu Jun 26 '12 at 03:33
  • There is an OnCreate()/WM_CREATE message for every single control, but when you have a standard control in a dialog, that message is sent before you have a chance to subclass the window. – Joseph Willcoxson Jun 26 '12 at 14:23