I have a timer that I display to the user in a RichEdit20A
that is inside a CDialog
.
The problem is every time I update the RichEdit20A
, the screen flickers.
Since I have several RichEdit20A
in my Dialog, I have a method below that I use to update them. I have tried ModifyStyle(0, WS_CLIPCHILDREN, 0);
OnInitDialog
but it erases all my RichEdit20A
texts. I also tried RedrawWindow(Null,Null, RDW_Erase)
--Dialog still flickers and RedrawWindow(Null,Null, RDW_Invalidate)
--All the text gets written on top of the old one making it unreadable.
//UpdateData(TRUE);
if(!pRECtrl)
return;
CHARFORMAT cf = {0};
cf.cbSize = sizeof(cf);
cf.dwMask = (bold ? CFM_BOLD : 0) | (italic ? CFM_ITALIC : 0) | CFM_COLOR;
cf.dwEffects = (bold ? CFE_BOLD : 0) | (italic ? CFE_ITALIC : 0) |~CFE_AUTOCOLOR;
cf.crTextColor = color;
pRECtrl->SetSel(0, -1); // Set the cursor to the end of the text area and deselect everything.
pRECtrl->Clear();
pRECtrl->ReplaceSel(text);
// Apply formating to the just inserted text.
pRECtrl->SetSel(0, pRECtrl->GetTextLength());
pRECtrl->SetSelectionCharFormat(cf);
//UpdateData(FALSE);
Invalidate();
I know that Invalidate is what is causing the flickering and that double buffering(I've never done it before) is what is used to fix this kind of issue for CViews...and I don't know what to do to stop the flickering for a CDialog, which is the window I am using for my program. Any help would be appreciated. Thank you!