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