79173997

Date: 2024-11-10 01:43:09
Score: 1.5
Natty:
Report link

[SOLVED] Just to shed some light as to where the problem lied. I read a post here on SO suggesting that the default control ID in resource editor should be changed from the default control ID of ID_STATIC to something else such as ID_STATIC_TEXT now all is working. I hope this helps someone else having similar issues. I've posted working code that toggles the color of the static text control.

HBRUSH CFileRenamerDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
    CWnd* pWndT = pWnd->GetDlgItem(IDC_STATIC);

    static int nColor = 0x0;
    int rgbRedC = 0x000000FF;
    int rgbGreenC = 0x0000FF00;
    int rgbBlueC = 0x00FF0000;
    int regbBlackC = 0x00000000;

    // TODO:  Change any attributes of the DC here
    switch (nCtlColor)
    {
    case CTLCOLOR_STATIC:

        if (nColor == regbBlackC)
        {
            pDC->SetTextColor(RGB(0, 0, 255));
            nColor = rgbBlueC;
        }
        else if (nColor == rgbBlueC)
        {
            pDC->SetTextColor(RGB(255, 0, 0));
            nColor = rgbRedC;
        }
    }
    return hbr;
}

void CFileRenamerDlg::OnBnClickedGo()
{
    CWnd* pWnd = this->GetDlgItem(IDC_STATIC_TEXT);
    pWnd->Invalidate(0);
}
Reasons:
  • Whitelisted phrase (-1): hope this helps
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): having similar issue
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: blogger6799