下边是得到password密码框密码的源代码!你可以通过这段delphi代码得到你要的得到的password框的代码
// 显示鼠标当前所在的文本框内容
function ShowWindowText():string;
var
pPoint:TPoint;
WinText:string;
mTextChar;
hWnd:Integer;
begin
GetCursorPos(pPoint);
SetLength(WinText,256);
hWnd:=WindowFromPoint(pPoint);
GetWindowText(hWND,PChar(WinText),256);
SetLength(WinText,StrLen(PChar(WinText)));
result:=WinText;
end;
而windows有的密码框控件对这个消息进行了处理,下边是一个控件的代码:
unit uCEdit;
interface
uses Windows,StdCtrls,Messages,Classes;
TYPE
TCEdit=class(TEdit)
private
bEnable:boolean; // 允许使用
procedure WndProc(var Msg: TMessage);override;
public
constructor Create(AOwner: TComponent); override;
function MyGetText():string;
published
end;
procedure Register;
implementation
{ CEdit }
//注册控件
procedure Register;
begin
RegisterComponents('Additional', [TCEdit]);
end;
constructor TCEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
// 禁止使用
bEnable:=false;
end;
function TCEdit.MyGetText: string;
begin
// 程序本身还是用允许的
bEnable:=true;
result:=Text;
end;
procedure TCEdit.WndProc(var Msg: TMessage);
begin
if (Msg.Msg=WM_GETTEXT) or (Msg.Msg=EM_GETLINE) then
begin
if bEnable then
begin
bEnable:=false;
inherited;
end;
end
else inherited;
end;