Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Background color of Edit control within a toolbar

27 views
Skip to first unread message

Drew Tennenbaum

unread,
Apr 26, 2002, 1:03:53 PM4/26/02
to
How would I change the color of an edit control within a toolbar?

I'd like to keep this as clean as possible, so I derived my own class from
CEdit.

I overrode the WM_ERASEBKGND message, however I can't seem to get the DC for
the actual edit control. When I do a PatBlt it changes the color of the
toolbar, and not the edit control.

Any ideas?


Jeff Partch

unread,
Apr 26, 2002, 1:21:11 PM4/26/02
to
Hi!

Well, the EDIT WNDCLASS has the CS_PARENTDC style, so what
you say makes sense in that respect. Anyway, try handling
the WM_CTLCOLOREDIT or WM_CTLCOLOR/CTLCOLOR_EDIT message
in the parent or the reflected (=WM_CTLCOLOR) message in a
derived CEdit subclass.

--
Jeff Partch

>.
>

Drew Tennenbaum

unread,
Apr 26, 2002, 3:59:35 PM4/26/02
to
Great! Thanks for the help. I handled the reflected message and it works
almost perfectly.

Maybe you or someone else knows what could be causing this..

My edit control has a spin control attached to it. It appears that no matter
what side it is attached on, about 1 line of pixels is being painted over by
the edit control. And when I lose focus from the edit control and the text
selection disappears, a second line of pixels is painted over by the edit
control.

I'm running Win XP and MFC 7.0-

My code to create the edit and spinner looks like this:

if (!m_wndEditDelay.Create(WS_TABSTOP | ES_NUMBER | ES_CENTER | WS_VISIBLE |
WS_CHILD,

rect, &m_wndToolBar, ID_EDIT_DELAY))

{

TRACE0("Failed to create Delay edit control.\n");

return -1;

}

if (!m_wndSpinDelay.Create(WS_CHILD | WS_VISIBLE | // dwStyle

UDS_ALIGNLEFT | UDS_SETBUDDYINT | UDS_ARROWKEYS,

rect, // rect

&m_wndToolBar, // CWnd* pParentWnd

ID_SPIN_DELAY)) // UINT nID))

{

TRACE0("Failed to create delay spin control.\n");

return -1; // fail to create

}

m_wndSpinDelay.SetBuddy(&m_wndEditDelay);

"Jeff Partch" <airb...@airmail.net> wrote in message
news:6ccb01c1ed46$c2fb5770$9ee62ecf@tkmsftngxa05...

0 new messages