Solved

Treatment of colors in a TStatic or TEdit class ?

Posted on 1997-05-29
8
484 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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
 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
XML problem with Internet Explorer 7 45
Migrating to Exchange 2013 4 45
Technology stack suggestions 4 63
Grunt script for Build Process 1 29
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
The viewer will learn how to count occurrences of each item in an array.
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…

773 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