Link to home
Start Free TrialLog in
Avatar of sma_soft
sma_soft

asked on

Change Color of an Object with API Functions

How to change the color of an Object using API Functions ?
Like Delphi's Form Objects (Label , CheckBox , Button , ... ) which you can change the COLOR property of them. and in VB is like this , too.
I've tried the SetTextColor , CreatePen , SelectObject and some other GDI Functions but they had no result.
Can someone help me please ?
thx - SMA
Avatar of robert_marquardt
robert_marquardt

TButton wraps the standard button windows control.
All the colors of these standard controls come from the registry. You change them in the Display Control Panel.
Avatar of Wim ten Brink
The WinControls have a canvas. For this canvas you can set the pen color and brush color. These values are used to draw these controls. Some controls have even more properties that contain other colors and font information. But in general there's no API call that can be used to change the color, because when the control redraws itself, it will revert to the previous color.
TButton is just a wrapper for the Windows button control as robert said
so if you want to change the color of one specific button, your best option is just to use a third party component, there are MANY available, just look at Torrys for color button
hello sma_soft , , there is a large amount of information about the subject of  API functions and how to use them, , , Do you have a more specific  problem or question about something you want to do?  A certain control that you want to change color?  A TLable is NOT a windowed control, so it don't do API, also some controls do not respond to a color change (a system BUTTON does not want to do a change of Color, also a TCheckBox is a system BUTTON). . . And a different type of system Control will have different typs of methods for changing them. . .
What is it you are trying to do? Or are you wanting info about using API methods?
Avatar of sma_soft

ASKER

BlackTigerX , I know about third-party Components , but I want to know how to this job with API Functions.
Because everything done in the Win32 Programs , are encapsulated of APIs.


Slick812 , First Thank you for your Guides.
Second , I've Created my Form using Pure-API. (CreateWindowEx , RegisterClassEx , etc.) I didn't use TForm.
and I also created a STATIC control using CreateWindowEx. (Against of Delphi's TLabel , it has a hWnd and can implement APIs.)
And I want to change the color of this Static Control using API. Because this is not a Delphi component and hasn't a COLOR property to set.
That's what I mean.
thx - SMA
The problem is that a Windows button simply does not react to any way to change its colors via Win32 API.
The only reaction is to a WM_SETTINGSCHANGE (aka WM_WININICHANGE) which is broadcast when the system colors in the Display Control Panel get changed.
robert_marquardt , I don't want to change the Windows's Colors. in Control Panel Display Settings. Because this will change colors of all objects. I want to change the color of one of my objects.
For Example in Delphi we write:
Edit1.Font.Color:=clRed;
I want to to this job with API Functions.
Did i tell already that it is *impossible* with TButton?
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

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