Thursday, July 23, 2009

How to Enable Password Mask in Editbox?

You have to enable ES_PASSWORD style of editbox and have to call SetPasswordChar() to set the Password masking character. You can do it in CDialog::OnInitDialog(). See the code snippet below.

BOOL CRabbitDlg::OnInitDialog()
{
...

// Get the Edit by using CtrlID.
CEdit* pEdit = (CEdit*) GetDlgItem( IDC_EDIT_PASSWORD );

// Set the password char.
pEdit->SetPasswordChar( '*' );

// Now modify the style to enable ES_PASSWORD.
pEdit->ModifyStyle( 0, ES_PASSWORD );

return TRUE;
}


0 comments:

  © Free Blogger Templates Blogger Theme II by Ourblogtemplates.com 2008

Back to TOP