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

    CEdit custom painting ?

    Hi!

    I'd like to use a customized CEdit-control which displays a gray text inside
    if the control ist empty, otherwise the
    user input (I've seen that in a commercial software but can't remember the
    name). I tried to overwrite the OnPaint
    but got not the result I wanted. Has anybody done this before?

    Ciao,
    Alex



  2. #2
    Join Date
    May 1999
    Posts
    35

    Re: CEdit custom painting ?

    Hi,

    you have to create a message handler for the message ON_WM_CTLCOLORREFLECT and then you can set the text and back color like this:

    HBRUSH CMyEdit::CtlColor(CDC* pDC, UINT nCtlColor)
    {
    pDC->SetTextColor(textcol);
    pDC->SetBkColor(backcol);

    return brush; // brush is a CBrush object, created with CreateSolidBrush(backcol)
    }

    Greetings, Jörg



  3. #3
    Join Date
    May 1999
    Posts
    5

    Re: CEdit custom painting ?

    Sorry, we misunderstood. The problem is not setting the colors (it works great the way you described), but doing custom painting (not only changing some colors) inside the CEdit (here: drawing some static, gayed text when the control ist "empty").

    Thank you for your reply and I hope it's now more clearly what I want to do.


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