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
    2

    changing text color

    How do I change the text color on my document. Below is my code for getting my selected color from the CColorDialog box which I have implemented in my application. I just don't know what to do with the data I have received.

    Any and all comments welcome!!!

    void CPropPage1::OnFont()
    {
    // get value from the register
    int SelectedColor = AfxGetApp()->GetProfileInt("Page1", "Color", 0);
    // create a dialog color box
    CColorDialog *pColor;
    // set the default color to the value retrieved from the registry
    pColor = new CColorDialog(SelectedColor);
    if (pColor->DoModal() == IDOK)
    {
    // save the color selected
    SelectedColor = pColor->GetColor();
    }
    // save this value to the registry for later use
    AfxGetApp()->WriteProfileInt("Page1", "Color", SelectedColor);
    }



  2. #2
    Join Date
    May 1999
    Posts
    69

    Re: changing text color

    It depends on how you're rendering the text. The document normally just holds the information you want to display, with a series of views implementing the display.

    In a lot of cases the view is a normal window and all display is carried out through a handler of the WM_PAINT message (namely OnPaint). If you are using this and you have a command to write the text (e.g. TextOut) you need to call SetTextColor before hand on the Device context available within the paint handler.



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