这些就应该够了。[
],适合95/98/me/2000/xp
{-------------------------------------------------------------------------------}
{系统的回调过程,在本过程内发送显示/隐藏密码的消息}
function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;
var
buffer: array[0..255] of Char;
begin
GetClassName(hwnd, buffer, 256);
//if StrPas(Buffer) = 'TEdit' then //找TEdit控件
begin
if lparam = 0 then
PostMessage(hwnd, EM_SETPASSWORDCHAR, longint(0), 0)
else
PostMessage(hwnd, EM_SETPASSWORDCHAR, longint('*'), 0);
InvalidateRgn(hwnd, 0, True);
Result := True; //终止循环
end;
end;
{-------------------------------------------------------------------------------}
{显示/隐藏所有窗体密码,本部分枚举所有窗体}
procedure ShowAll(lparam: Integer);
var
Window_Handle, Hand: Integer;
begin
Window_Handle := GetWindow(Application.Handle, GW_HWNDFIRST);
while Window_Handle <> 0 do
begin
if Window_Handle <> 0 then
begin
EnumChildWindows(Window_Handle, @EnumChildWindowsProc, lparam);
end;
Window_Handle := GetWindow(Window_Handle, GW_HWNDNEXT);
end;
end;
{-------------------------------------------------------------------------------}
{响应按键}
procedure TFrm_ShowPass.sbtn_ShowPassClick(Sender: TObject);
begin
ShowAll(0);
end;
procedure TFrm_ShowPass.sbtn_hidePassClick(Sender: TObject);
begin
ShowAll(1);
end;