本文整理自网络,侵删。
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Menus;
type TForm1 = class(TForm) Image1: TImage; Timer1: TTimer; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; PopupMenu1: TPopupMenu; N1: TMenuItem; TrayIcon1: TTrayIcon; procedure Timer1Timer(Sender: TObject); procedure FormCreate(Sender: TObject); procedure N1Click(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } procedure hotykey(var msg:TMessage); message WM_HOTKEY; end;
var Form1: TForm1; HotKey:Integer; i:integer;
implementation
{$R *.dfm}
procedure TForm1.hotykey(var msg:TMessage); //热键响应事件beginif (msg.LParamLo=0) and (msg.LParamHi=113) thenbeginif i=0 then begin Timer1.Enabled:=False; i:=1; end else begin Timer1.Enabled:=True; i:=0; end;end; end;
procedure TForm1.Timer1Timer(Sender: TObject);vardc: HDC;zhuo: TCanvas;pt: tpoint;x1,y1:Integer ;i,j:integer;X,Y,b,n,k,l:longint; t,clr:tcolor; r:byte; g:byte; f:byte; DesktopDC: HDC; er:string;beginGetCursorPos(pt); //得到鼠标的坐标x1:=image1.Width ;y1:=image1.Height ;
DesktopDC :=GetWindowDC(GetDesktopWindow);t:=GetPixel(DesktopDC,pt.X,pt.Y);r:=getrvalue(t);g:=getgvalue(t);f:=getbvalue(t);label1.Caption:='红:'+inttostr(r)+' ';label2.Caption:='绿:'+inttostr(g)+' ';label3.Caption:='蓝:'+inttostr(f)+' ';er:=IntToHex(TColor(RGB(f,g,r)),8);er:=copy(er,3,6);label4.Caption:='#'+er;
dc := Getdc(0); //得到桌面的DCzhuo := TCanvas.Create;
zhuo.Handle := dc; //建一个屏幕的对像image1.Canvas.copyrect //开始拷屏(rect(0, 0,image1.Width ,image1.Height ), //图像控件左边=0,右边=0, zhuo, // 图像显示控件的全部 rect(pt.X - 20, pt.Y - 20, //要放大的倍 就改变图像控件的大小 pt.X + 20, pt.Y + 20));
zhuo.Free;ReleaseDC(0, dc);X:=129; //获取屏幕最大XY:=121; //获取屏幕最大Yb:=X div 2;n:=Y div 2;image1.Canvas.Pen.Color:=clblack;image1.Canvas.Pen.Width :=0;image1.Canvas.MoveTo(b-10,n); {直线起点}image1.Canvas.LineTo(b+10,n); {直线终点}image1.Canvas.MoveTo(b,n-10); {直线起点}image1.Canvas.LineTo(b,n+10);
k:=GetSystemMetrics(SM_CXSCREEN);l:=GetSystemMetrics(SM_CYSCREEN);
if (pt.X>k-300)and(pt.X<k) thenbeginendelsebeginForm1.Left:=pt.X+100;end;
if (pt.Y>l-300)and(pt.Y<l) thenbeginendelsebeginForm1.Top:=pt.Y+100;end;
if (pt.X>k-300)and(pt.X<k) thenbeginForm1.Left:=pt.X-200;end;if (pt.Y>l-300)and(pt.Y<l) thenbeginForm1.Top:=pt.Y-200;end;
releasedc(0,dc);
end;
procedure TForm1.FormCreate(Sender: TObject);begini:=0;
TransparentColor:=True;TransparentColorValue:=25;Color:=Form1.TransparentColorValue;
HotKey:=GlobalAddAtom('HotKey'); //全局热键IDRegisterHotKey(handle,HotKey,0,113); //注册全局热键end;
procedure TForm1.N1Click(Sender: TObject);beginForm1.Close;end;
procedure TForm1.FormDestroy(Sender: TObject);beginUnRegisterHotKey(handle,HotKey);end;
end.
相关阅读 >>
Delphi 几个dataset数据导出到xml word excel txt html的函数
Delphi android / ios应用程序中使用tgeocoder类进行反向地理编码(从位置信息中获取地址)
更多相关阅读请进入《Delphi》频道 >>