delphi之屏幕取色
来源:http://www.delphitop.com/html/tuxiang/723.html
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.
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。