http://www.csdn.net/expert/topic/230/230141.shtm有
解决方案 »
- 我等你,等到我心痛,面向对象一问题。
- 如何去掉Form窗体上的最小化按钮和最大化按钮
- 【新手提问】关于数据库操作的异常处理
- 寻找控件: 能够可视化编辑、生成 html 的控件
- 请问如何在delphi中进行超连接
- 为什么在编译时出现无法找到"System.pas"?
- web应用程序发布后,用IE浏览器打开时出现网页错误
- DELPHI如何使用指针?
- 请教web ISAPI应用程序的多线程问题
- 数据库配合问题
- 你知道一名程序员的隐形工资从哪里来吗?
- 我用ado_table连接sql_server数据库上的一个表,表中记录数在1万条左右,仅仅将ado_table open一下就要花费7、8秒时间。该怎么办?
color:tcolorref;
begin
dc:=tcanvas.create;
dc.handle:=getdc(0);
color:=getPixel(dc.Handle,x,y);
end;
var Color:ColorRef;
begin
DC:=GetDC(0);
Color:=GetPixel(DC,x,y);//x,y为坐标
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TfrmGetColor = class(TForm)
pColor: TPanel;
btnGet: TButton;
btnExit: TButton;
lInfo: TLabel;
btnStop: TButton;
tmCursor: TTimer;
procedure btnGetClick(Sender: TObject);
procedure btnExitClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnStopClick(Sender: TObject);
procedure tmCursorTimer(Sender: TObject);
private
isSet:Boolean;
{ Private declarations }
public
{ Public declarations }
end;var
frmGetColor: TfrmGetColor;implementation{$R *.dfm}procedure TfrmGetColor.btnGetClick(Sender: TObject);
begin
if not isSet then
begin
isSet:=True;
tmCursor.Enabled:=True;
end;
end;procedure TfrmGetColor.btnExitClick(Sender: TObject);
begin
Close;
end;procedure TfrmGetColor.FormShow(Sender: TObject);
begin
frmGetColor.Left:=(Screen.Width-frmGetColor.Width) div 2;
frmGetColor.Top:=(Screen.Height-frmGetColor.Height) div 2;
end;
procedure TfrmGetColor.btnStopClick(Sender: TObject);
begin
if isSet then
begin
isSet:=False;
tmCursor.Enabled:=False;
end;
end;procedure TfrmGetColor.tmCursorTimer(Sender: TObject);
var
mDC:HDC;
mP:TPoint;
mColor:TColor;
mCanvas:TCanvas;
mRGB:LongInt;
mR,mG,mB:Integer;
begin
tmCursor.Enabled:=False;
try
mDC:=GetDC(0);
mCanvas:=TCanvas.Create;
try
mCanvas.Handle:=mDC;
GetCursorPos(mP);
mColor:=mCanvas.Pixels[mP.X,mP.Y];
mRGB:=ColorToRGB(mColor);
mB:=mRGB div $00010000;
mG:=(mRGB mod $00010000) div $00000100;
mR:=mRGB mod $00000100;
frmGetColor.Color:=mColor;
//lInfo.Font.Color:=TColor(mRGB xor $ffffffff);
lInfo.Caption:='R:'+IntToStr(mR)+#13+'G:'+IntToStr(mG)+#13+'B:'+IntToStr(mB);
lInfo.Caption:=lInfo.Caption+#13+'X:'+IntToStr(mP.X)+'; Y:'+IntTOStr(mP.Y);
finally
ReleaseDC(0,mDC);
mCanvas.Free;
end;
finally
if isSet then
tmCursor.Enabled:=true;
end;
end;end.
mDC:=GetDC(0);
mCanvas:=TCanvas.Create;
try
mCanvas.Handle:=mDC;
GetCursorPos(mP);
mColor:=mCanvas.Pixels[mP.X,mP.Y];
mRGB:=ColorToRGB(mColor);
mB:=mRGB div $00010000;
mG:=(mRGB mod $00010000) div $00000100;
mR:=mRGB mod $00000100;
frmGetColor.Color:=mColor;
//lInfo.Font.Color:=TColor(mRGB xor $ffffffff);
lInfo.Caption:='R:'+IntToStr(mR)+#13+'G:'+IntToStr(mG)+#13+'B:'+IntToStr(mB);
lInfo.Caption:=lInfo.Caption+#13+'X:'+IntToStr(mP.X)+'; Y:'+IntTOStr(mP.Y);
finally
ReleaseDC(0,mDC);
mCanvas.Free;
end;