how to change background color of a static text control (when a button is pushed or in a timer) in mfc?

Viewed 33883

I know it can be done with OnCtlColor(), but it changes colors when the form is being loaded and the static texts are to be drawn, I want to do it after form is loaded, with a timer maybe, I searched for a solution but I didn't find a clear one, this is what I wrote:

void CTabFive::OnBnClickedButton1()
{
    // TODO: Add your control notification handler code here
    CWnd* pWnd = this->GetDlgItem(IDC_Chromosome1);
    CDC* dc = pWnd->GetDC();
    dc->SetBkColor(RGB(200,0,0));
    pWnd->Invalidate();
    pWnd->UpdateWindow();
    Invalidate();
    UpdateWindow();
    //flag = true;
}
1 Answers
Related