Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Treatment of colors in a TStatic or TEdit class ?

Posted on 1997-05-29
8
Medium Priority
?
510 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

721 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