Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get pixel color of parent control?

165 views
Skip to first unread message

Jon

unread,
May 28, 2008, 11:05:56 AM5/28/08
to
Hello,

How to get pixel color of parent control?

Thank you!

Peter Below (TeamB)

unread,
May 28, 2008, 3:11:22 PM5/28/08
to
Jon wrote:

Parent.Color?

--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com

Jon

unread,
May 29, 2008, 2:27:02 AM5/29/08
to
Parent is not in one color, I need to pick a color of particular pixel.

Marc Rohloff [TeamB]

unread,
May 29, 2008, 8:43:11 AM5/29/08
to
On Thu, 29 May 2008 09:27:02 +0300, Jon wrote:

> Parent is not in one color, I need to pick a color of particular pixel.

What do you want to do with this color once you get it? It is not
common to want a single pixel, most people are trying to work with a
block of pixels in which case accessing them one by one will be very
inefficient.

--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com

Remy Lebeau (TeamB)

unread,
May 29, 2008, 1:58:03 PM5/29/08
to

"Jon" <j...@one.lt> wrote in message news:483e...@newsgroups.borland.com...

> Parent is not in one color, I need to pick a color of particular pixel.

You can use a TControlCanvas instance to access the individual Pixels of any
TControl, ie:

var
LCanvas: TControlCanvas;
LColor: TColor;
begin
//...
LCanvas := TControlCanvas.Create;
try
LCanvas.Control := Parent;
LColor := LCanvas.Pixels[X, Y];
finally
LCanvas.Free;
end;
//...
end;


Gambit


Peter Below (TeamB)

unread,
May 29, 2008, 1:56:26 PM5/29/08
to
Jon wrote:

> Parent is not in one color, I need to pick a color of particular
> pixel.

CV:= TControlCanvas.Create;
try
CV.Control := Parent;
aColor := CV.Pixels[X, Y];
finally
CV.Free
end;

This only works for parts of the parent control that are visible and
the X and Y coordinates are relative to the client area of the parent
control.

Jon

unread,
May 30, 2008, 5:14:57 AM5/30/08
to
Thank You, this really helped me!
0 new messages