Solved

Treatment of colors in a TStatic or TEdit class ?

Posted on 1997-05-29
8
497 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
Technology Partners: 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 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP radio buttons with email not sending 24 114
How to translate path in URL with PHP? 11 52
Problem to page 4 105
Grunt Copy file to another destination. 1 95
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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…

734 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