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
    4

    How can I change the colour of the Fonts in a readonly editview

    I want to change the color of the font in an readonly editview ,but I don't know how.I know I can set the font in InitialUpdate()function of the Editview.
    But I do not know how to set the color of the Font in the readonly editview,
    Please hlp me if you can. Thank you!


  2. #2
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: How can I change the colour of the Fonts in a readonly editview

    If this was an edit control, the following should work:

    Add a handler for the WM_CTL_COLOR message to the parent of the edit control. In the code it generates, put the following:

    ---HBRUSH CMyDlgOrWnd::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
    {
    HBRUSH hBrBkgnd = NULL ;
    UINT uID ;

    uID = pWnd->GetDlgCtrlID();
    if (nCtlColor == CTLCOLOR_EDIT && uID == IDC_MY_EDIT_CONTROL)
    {
    pDC->SetBkColor(desired back colour);
    pDC->SetTextColor(desired text colour);
    hBrBkgnd = ::GetSysColorBrush(COLOR_WINDOW or whatever);
    // Note - if you create a custom brush for the background, the brush
    // MUST remain in existence outside of this routine - so make it a
    // member of this class.
    }

    // We must ONLY call the base class if this call was not for our edit
    // control - otherwise it will override our settings.
    if (hBrBkgnd == NULL)
    hBrBkgnd = CBaseClass::OnCtlColor(pDC, pWnd, nCtlColor);

    return hBrBkgnd ;
    }




    ---

    I don't know if this works for an edit control embedded in an edit view; you would have to check the edit view's code for the ID of the embedded edit control.

    Does this help? If not, I'll have a little fiddle to see if I can sort it.






    --
    Jason Teagle
    [email protected]

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