我的用户在组合框中输入密码,所以我想显示*
用户键入的内容。到目前为止没有问题。下面显示的例程完美运行。但是,我也想让用户选择显示密码。当我使用 SetPasswordChar=false 调用下面的例程时,它会发送参数为零的 EM_SETTPASSWORDCHAR。我希望组合框显示用户输入的文本。但它仍然显示*
。知道我错过了什么吗?
//==============================================================================
// SetComboBoxPasswordChar
//------------------------------------------------------------------------------
// Set the Password Char for a tComboBox.
//
// This is done using by sending an EM_SETPASSWORDCHAR message to the edit box
// sub-control of the combo box.
//
//http://msdn.microsoft.com/en-us/library/windows/desktop/bb761653(v=vs.85).aspx
//
// wParam - The character to be displayed in place of the characters typed by
// the user. If this parameter is zero, the control removes the current password
// character and displays the characters typed by the user.
//==============================================================================
procedure SetComboBoxPasswordChar
( const nComboBox : tComboBox;
const nSetPasswordChar : boolean );
var
C : integer;
H : tHandle;
begin
// Get handle of the combo box
H := nComboBox . Handle;
// Get handle of the edit-box portion of the combo box
H := GetWindow ( H, GW_CHILD );
// If nSetPasswordChar is true,
// set password char to asterisk
// Otherwise, clear the password char
if nSetPasswordChar then
C := ord('*')
else
C := 0;
SendMessage ( H, EM_SETPASSWORDCHAR, C, 0 );
end;