سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top