Link to home
Start Free TrialLog in
Avatar of mike_marquet
mike_marquet

asked on

Treatment of colors in a TStatic or TEdit class ?

How can I treat the foreground and background color
of a derivered TStatic or TEdit class in
the class himself and not the parent class ?
(With BC 4.52)

I have try to use GetDC with SetTextColor and SetBkgndColor
in the derivered TEdit class but it doesn't work.
I have also try to use the WM_CTLCOLOR in the derivered
TEdit class but the event never arrived at my TEdit class
because the parent treat this message before.

How can I activate the WM_CTLCOLOR for the derivered TEdit
class.

EMail : mike_marquet@hotmail.com
Avatar of AVaulin
AVaulin
Flag of Ukraine image

Use GetDC and SetTextColor and SetBkColor API functions for your classes. If it will no help handle WM_CTLCOLOR for them.
Will you accept or reject this answer?
Avatar of mike_marquet
mike_marquet

ASKER

Edited text of question
I have try to use GetDC with SetTextColor and SetBkgndColor
in my derivered TEdit class (Function SetupWindow, Paint, ...)
but it doesn't work.

I have try to use the WM_CTLCOLOR message for the TEdit class
but the message is never generated for it because the parent
treat this message before.

How can I activate the WM_CTLCOLOR for the derivered TEdit
class.
There is no way to use WM_CTLCOLOR in control itself, you have to
handle it at parent level, because each control is managed by
its parent.

add this in parent message tabel define.

    EV_WM_CTLCOLOR,

add this function for control background

HBRUSH TControlParentWindow::EvCtlColor(HDC hDC, HWND hWndChild, uint ctlType)
    {
    HBRUSH br = GetYourOwnControlBrush();
    if(br) return br;
    return TWindow::EvCtlColor(hDC, hWndChild, ctlType);
    }


I doesn't want to treat the color in the parent class.

I want to treat it in the TEdit class, this was the question.

VBX make it so !!!!!
ASKER CERTIFIED SOLUTION
Avatar of ocurance
ocurance

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you going to score this answer?