我这里有一个简单但是完整的例子,看看(1个Button, 1个Edit, 1个Timer):
unit ShowPasswd_pas;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Txt: TEdit;
Tim: TTimer;
btCmd: TButton;
procedure btCmdClick(Sender: TObject);
procedure TimTimer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
X,Y:Integer;
Pos:TPoint;
hResult,hLength:LongInt;
hNow: THandle;implementation{$R *.DFM}
function GetText(hWndNow:Integer):String;
var
buf:Array of Char;
t:String;
i:Integer;
begin
hLength:=SendMessage(hWndNow,WM_GETTEXTLENGTH,0,0);
if hLength>0 then
begin
SetLength(buf,hLength+1);
SendMessage(hWndNow,WM_GETTEXT,hLength+1,LPARAM(buf));
for i:=0 to Length(buf) do
t:=t+buf[i]; GetText:=t;
end
else
GetText:='';
end;
procedure TForm1.btCmdClick(Sender: TObject);
begin
if btCMD.Caption='Start' then
begin
btCMD.Caption:='Stop';
Tim.Enabled:=true;
end
else
begin
btCMD.Caption:='Start';
Tim.Enabled:=false;
end
end;procedure TForm1.TimTimer(Sender: TObject);
var
t:array [0..254] of char;
begin
GetCursorPos(Pos);
hNow:=WindowFromPoint(Pos);
GetClassName(hNow,@t,255);
if (t[0] = 'E') and (t[1] = 'd') and (t[2] = 'i') and (t[3] = 't') and (t[4] = #0) then
begin
if hNow<>Form1.Handle then
Txt.Text:=GetText(hNow);
end
else
Txt.Text:= 'not a EDIT!';
// GetClass(t);
// Txt.Text:=t;
// Tim.Enabled:=false;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Tim.Enabled:=false;
end;end.
unit ShowPasswd_pas;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Txt: TEdit;
Tim: TTimer;
btCmd: TButton;
procedure btCmdClick(Sender: TObject);
procedure TimTimer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
X,Y:Integer;
Pos:TPoint;
hResult,hLength:LongInt;
hNow: THandle;implementation{$R *.DFM}
function GetText(hWndNow:Integer):String;
var
buf:Array of Char;
t:String;
i:Integer;
begin
hLength:=SendMessage(hWndNow,WM_GETTEXTLENGTH,0,0);
if hLength>0 then
begin
SetLength(buf,hLength+1);
SendMessage(hWndNow,WM_GETTEXT,hLength+1,LPARAM(buf));
for i:=0 to Length(buf) do
t:=t+buf[i]; GetText:=t;
end
else
GetText:='';
end;
procedure TForm1.btCmdClick(Sender: TObject);
begin
if btCMD.Caption='Start' then
begin
btCMD.Caption:='Stop';
Tim.Enabled:=true;
end
else
begin
btCMD.Caption:='Start';
Tim.Enabled:=false;
end
end;procedure TForm1.TimTimer(Sender: TObject);
var
t:array [0..254] of char;
begin
GetCursorPos(Pos);
hNow:=WindowFromPoint(Pos);
GetClassName(hNow,@t,255);
if (t[0] = 'E') and (t[1] = 'd') and (t[2] = 'i') and (t[3] = 't') and (t[4] = #0) then
begin
if hNow<>Form1.Handle then
Txt.Text:=GetText(hNow);
end
else
Txt.Text:= 'not a EDIT!';
// GetClass(t);
// Txt.Text:=t;
// Tim.Enabled:=false;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Tim.Enabled:=false;
end;end.
功能还比较强大
去 csdn 共享软件 网络辅助 中去下载 i-Fresher吧
我也提供原代码。
相信你需要的就是这个了。
你好,能给我源代码吗?谢谢! Email:[email protected]
感谢你为我提供源代码,我就此有一点问题想请教:为什么只能显示出一小部分窗口的控件(Edit编辑框)的星号密码呢?任意编一个程序,其Edit编辑框的PasswordChar属性定义为'*',通过你提供的源代码所编译的程序,就不能显示出相应的Edit编辑框中的字符串……
p:tpoint
memo1.clear;
getcursorpos(p);
hd1:=windowfrompoint(p);while not (hd1=0) do
begin
getclassname(hd1,buf,50);
memo1.lines.add(buf);
hd1:=getparent(hd1);
end;
Sorry,这是由于我的判断条件过于严格造成的,改写为:
procedure TForm1.TimTimer(Sender: TObject);
var
t:array [0..254] of char;
tt: String;
begin
GetCursorPos(Pos);
hNow:=WindowFromPoint(Pos);
GetClassName(hNow,@t,255);
tt:= StrPas(t);
if (tt = 'Edit') or (tt = 'TEdit') then <-关键在这里
begin
if hNow<>Form1.Handle then
Txt.Text:=GetText(hNow);
end
else
Txt.Text:= 'not a EDIT!';
end;
你好,能给我i-Fresher的源代码吗?谢谢! Email:[email protected]
你好,能给我i-Fresher的源代码吗?谢谢! Email:[email protected]
我看见了:)
看你的邮箱吧。
请问:你不是发的附件吗?
我收到的是这些东东,有很多乱码,看不懂: Date: Sun, 21 Jan 2001 07:58:08 GMT
Mime-version: 1.0
Content-type: multipart/mixed; boundary="=_0_26175_980063888"; charset="us-ascii
"This is a MIME-formatted message. If you see this text it means that your
mail software cannot handle MIME-formatted messages.--=_0_26175_980063888
Content-Type: text/plain; charset=us-ascii
--=_0_26175_980063888
Content-Type: application/zip; name="source.zip"
Content-Disposition: inline; filename="source.zip"
Content-Transfer-Encoding: base64UEsDBBQAAAAIAIerkinDmrKxjwcAADkPAAAJAAAAYWJvdXQuZGN17Vb/bxvlGX+fa2w/TTLXS92Q
hTRNohAlXWLRpKrarWL54rjNlobUdr/AtmqXu9fOtec7c3duk2paA1TQUjFKG9gQaFu1qatEQYA0
SC2EAtkyVqEIoSx0sB+gIDbo1h8mTWza1ux972zn3Cv7C3ayXz/v+/nc877PV7+nwhv+tm0NIQ8/
e6aD8OdJsj27WhzTc1YkK5r3PSp3EKMwj8Z2Xc2c6RBkTFjygGWoZtfPzw+l/MlhcYyqZzc/3ZIK
这是怎么回事哟? 能不能再用附件的形式发给我? 谢谢你了!
OK,已经收到你的源代码,谢谢你!
(我已在“专家门诊”中提出来了)
1. 如何实现象Oicq那样用户之间文件的相互传输?[Delphi]
2. 如何发大和缩小图标(*.ico)?格式为*.bmp等等的图可以放大或缩小,但是*.ico却不知道怎么实现,请问各位大侠怎样才能实现?[Delphi]