码迷,mamicode.com
首页 > 其他好文 > 详细

屏幕取色

时间:2019-01-25 12:53:05      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:control   poi   proc   tco   代码   cap   interface   sys   lse   

代码:
[code=delphi]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Timer1: TTimer;
    Edit1: TEdit;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Timer1.Enabled := False;
  Timer1.Interval := 100;
  Button1.Default := True;
  Button1.Caption := ‘开始‘;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Timer1.Enabled := not Timer1.Enabled;
  if Timer1.Enabled then Button1.Caption := ‘停止‘
else Button1.Caption := ‘开始‘;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  pt: TPoint;
  c: TColor;
begin
  GetCursorPos(pt);
  c := GetPixel(GetDC(0), pt.X, pt.Y);
  Self.Color := c;
  Edit1.Text := Format(‘#%.6x‘, [c]);
end;

end.[/code]

屏幕取色

标签:control   poi   proc   tco   代码   cap   interface   sys   lse   

原文地址:https://www.cnblogs.com/qiu18359243869/p/10318727.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!