密码查看器<br>awin.y365.com Delphi梦工场 <br><br><br><br>源程序在下面,里面还演示了怎样使用自定义光标,不过这个东西对win2000好像没有什么作用,如果有人知道怎么解决这个问题,一定要告诉我一声!<br><br>工程文件如下:<br>program viewpass;<br><br>uses<br>Forms,<br>pass in 'pass.pas' {Form1};<br><br>{$R *.RES}<br><br>begin<br>Application.Initialize;<br>Application.Title := 'passview';<br>Application.CreateForm(TForm1, Form1);<br>Application.Run;<br>end.<br><br>单元文件如下:<br>unit pass;<br><br>interface<br><br>uses<br>Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,<br>StdCtrls, ExtCtrls,shellapi;<br><br>const<br>crmycursor=2;//自定义光标的ID,必须大于0<br><br>type<br>TForm1 = class(TForm)<br>Edit1: TEdit;<br>Edit2: TEdit;<br>Panel1: TPanel;<br>Image1: TImage;<br>Button1: TButton;<br>Label1: TLabel;<br>Label2: TLabel;<br>Edit3: TEdit;<br>Label4: TLabel;<br>Panel2: TPanel;<br>Image2: TImage;<br>Image3: TImage;<br>Label5: TLabel;<br>CheckBox1: TCheckBox;<br>procedure Button1Click(Sender: TObject);<br>procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;<br>Shift: TShiftState; X, Y: Integer);<br>procedure FormCreate(Sender: TObject);<br>procedure FormMouseUp(Sender: TObject; Button: TMouseButton;<br>Shift: TShiftState; X, Y: Integer);<br>procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,<br>Y: Integer);<br>procedure CheckBox1Click(Sender: TObject);<br>procedure Label5Click(Sender: TObject);<br>private<br>{ Private declarations }<br>isdragging:boolean;<br>public<br>{ Public declarations }<br>end;<br><br>var<br>Form1: TForm1;<br><br>{$R mycursor.res}//包含自定义光标的资源文件,必须加上<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>close;<br>end;<br><br>procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;<br>Shift: TShiftState; X, Y: Integer);<br>begin<br>if isdragging=false then<br>begin<br>isdragging:=true;<br>image1.visible:=false;<br>screen.cursor:=crmycursor;//设置光标为自定义光标<br>setcapture(handle);//设置鼠标捕捉,重要<br>end;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>isdragging:=false;<br>screen.cursors[crmycursor]:=loadcursor(HINSTANCE,'pass');//从资源文件中装载自定义光标,pass为自定义资源文件中光标的文件名<br>try<br>case strtoint(copy(timetostr(time),5,1)) of<br>0..2:color:=clpurple;<br>3..5:color:=clblack;<br>6..7:color:=clinfobk;<br>8..9:color:=clbackground;<br>end;<br>except<br>color:=clbackground;<br>end;<br>end;<br><br>procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;<br>Shift: TShiftState; X, Y: Integer);<br>begin<br>if isdragging=true then<br>begin<br>isdragging:=false;<br>image1.visible:=true;<br>screen.Cursor:=crdefault;//恢复缺省的光标<br>releasecapture;//释放鼠标捕捉,重要<br>end;<br>end;<br><br>procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,<br>Y: Integer);<br>var<br>mousepoint:tpoint;<br>myhwnd:hwnd;<br>pass,classname:array [0..254] of char;<br>lens:integer;<br>begin<br>if isdragging=true then<br>begin<br>getcursorpos(mousepoint);//获得当前光标位置<br>myhwnd:=windowfrompoint(mousepoint);//获得光标处的窗口句柄<br>getclassname(myhwnd,classname,sizeof(classname));//获得窗口的类名<br>lens:=sendmessage(myhwnd,wm_gettextlength,0,0)+1;//取得密码长度<br>sendmessage(myhwnd,wm_gettext,lens,longint(@pass));//取得密码<br>if (defwindowproc(handle,wm_nchittest,0,getmessagepos)=htcaption) or (defwindowproc(handle,wm_nchittest,0,getmessagepos)=htclient) then<br>begin<br>edit1.Text:='本窜口中';<br>edit3.text:=';<br>edit2.Text:=';<br>end<br>else<br>begin<br>edit1.Text:=format('X:%d,Y:%d',[mousepoint.x,mousepoint.y]);<br>edit2.text:=string(pass);<br>edit3.text:=string(classname);<br>end;<br>end;<br>end;<br><br>procedure TForm1.CheckBox1Click(Sender: TObject);<br>begin<br>if checkbox1.checked then setwindowpos(handle,hwnd_topmost,left,top,width,height,0);//总在最前<br>end;<br><br>procedure TForm1.Label5Click(Sender: TObject);<br>begin<br>shellexecute(handle,'open',pchar('mailto:mhsxaw@163.com?subject=我的建议*_*'),nil,nil,9);<br>end;<br><br>end.<br><br><br><br><br>作者:不详<br>来源:不详<br><br>