花褪残红青杏小。燕子飞时,绿水人家绕。

delphi之屏幕取色

菜鸟编程 十五楼的鸟儿 30724浏览 0评论
上个预览图先:
delphi之屏幕取色 DELPHI 菜鸟编程  第1张
代码:
[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]

转载请注明:鸟儿博客 » delphi之屏幕取色

游客
发表我的评论 换个身份
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址