CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    3

    changing the color of text in MFC

    I am trying to change the color of the text in a text box in an MFC application, can anyone help me. Or if anyone knows a better type of control to use which would work in MFC that would be great too. Thanks


  2. #2
    Join Date
    May 1999
    Posts
    7

    Re: changing the color of text in MFC

    You have to overide OnCtlColor()
    as given below with the WM_CTLCOLOR inside

    BEGIN_MESSAGE_MAP

    HBRUSH CMydialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    if(nCtlColor == CTLCOLOR_STATIC)
    hbr = CreateSolidBrush(RGB(O,O,O);
    pDC->SetBkColor(RGB(O,O,O));
    pDC->SetTextColor(RGB(255,255,255
    ));


    // TODO: Return a different brush if the default is not desired
    return hbr;
    }


    the above code will have a black background

    and white text color for all the static text

    you have created.

    if you have still doubt mail at the same place

    kals

    Thanks for reading the mail.

    Expecting a postivie Reply

    kals

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured