VB InputBox 对话框星号保护隐私
Alias "PostMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Const EM_SETPASSWORDCHAR = &HCC
'hwnd 标识与定时器相关的窗口
'nIDEvent 指定一个非零定时器事件标识符
'uElapse 指定定时器事件之间的时间间隔
'lpTimerFunc 表示定时器事件发生后接收详细的函数的过程实例地址
Public Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) _
As Long
Private Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long) _
As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) _
As Long
Dim m_lngTimerId As Long
Private Sub Main()
'建立API时间,句柄参数这里没有窗体赋值为0,但需要保存计时器标识符供KillTimer使用
m_lngTimerId = SetTimer(0, 0, 1, AddressOf TimerProc)
'Prompt作为对话框消息出现的字符串表达式。
'Title显示对话框标题栏中的字符串表达式。如果省略 title,则把应用程序名放入标题栏中。
'Default显示文本框中的字符串表达式,在没有其它输入时作为缺省值。如果省略 default,则文本框为空。
Call InputBox("请输入姓名", "输入框")
End Sub
Public Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Dim lngHwnd As Long
lngHwnd = FindWindow(vbNullString, "输入框") '参数复制是Input的Title参数
lngHwnd = FindWindowEx(lngHwnd, 0, "Edit", vbNullString) '继续查找子窗口,使用TextBox类名"Edit"
If lngHwnd Then
Call PostMessage(lngHwnd, EM_SETPASSWORDCHAR, &H2A, 0) '&H2A是什么?就是*的AscII码42,这个参数为""就是不显示密码了。
Call KillTimer(0, m_lngTimerId) '关闭计时器
End If
End Sub
?