How to get pixel color of parent control?
Thank you!
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
> 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
> 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
> 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.