Solved

Treatment of colors in a TStatic or TEdit class ?

Posted on 1997-05-29
8
473 Views
Last Modified: 2013-12-26
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
0
Comment
Question by:mike_marquet
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 4

Expert Comment

by:AVaulin
ID: 1299213
Use GetDC and SetTextColor and SetBkColor API functions for your classes. If it will no help handle WM_CTLCOLOR for them.
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1299214
Will you accept or reject this answer?
0
 

Author Comment

by:mike_marquet
ID: 1299215
Edited text of question
0
 

Author Comment

by:mike_marquet
ID: 1299216
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.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 3

Expert Comment

by:gaohong
ID: 1299217
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);
    }


0
 

Author Comment

by:mike_marquet
ID: 1299218
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 !!!!!
0
 

Accepted Solution

by:
ocurance earned 100 total points
ID: 1299219
In the WM_Paint handler, you should be able to do the following.   After calling the TEdit::Paint() function, get that Window's DC, (TWindowDC dc(HWindow);),  and  set it's text color to your desired color.  Now get the edit control's text, GetText(...), and TextOut(...) the text in your choice of color!

Good luck,
Roger
0
 

Expert Comment

by:ocurance
ID: 1299220
Are you going to score this answer?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Auto Complete Using JQuery 5 71
How Fix Width of WordPress Mobile Site 13 70
css help 3 93
PHP PDO get the error if exists 3 61
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now