...get a pixel color of the desktop?

Author: Rainer K├╝mmerle
Homepage: http://www.thinklazy.de

Category: Graphic

function DesktopColor(const X, Y: Integer): TColor;
var
  
c: TCanvas;
begin
  
c := TCanvas.Create;
  try
    
c.Handle := GetWindowDC(GetDesktopWindow);
    Result   := GetPixel(c.Handle, X, Y);
  finally
    
c.Free;
  end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  
Pos: TPoint;
begin
  
GetCursorPos(Pos);
  Panel1.Color := DesktopColor(Pos.X, Pos.Y);
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base