0

プロジェクトにパスワードモードのテキストボックスがあります。ただし、これは、フォーカスがある場合は表示し、フォーカスを解除すると文字を非表示にする必要があります。

これは私のソースコードです。m_editBox は IDC_EDIT1 の制御変数です。

void CEditBoxTestDlg::OnEnSetfocusEdit1()
{
    //m_editBox.SetPasswordChar(0);
}

void CEditBoxTestDlg::OnEnKillfocusEdit1()
{
    //m_editBox.SetPasswordChar('*');            //1
    m_editBox.SendNotifyMessage(EM_SETPASSWORDCHAR, (WPARAM) '*', NULL);    //2
}

しかし、 OnEnKillfocusEdit() は明確に機能しません。私はそれをデバッグし、このモジュールに入ることを確認しました。

どうすればこの問題を解決できますか。ありがとう。

4

1 に答える 1

0

私はそれを自分でやりました。sendmessage の後に Invalidate() 関数を見逃していました。また、SetpasswordChar()、SendNotifyMessage、PostMessage() も正常に動作することを確認しました。

これが私のコードです:

void CEditBoxTestDlg::OnEnSetfocusEdit1()
{
    m_editBox.SetPasswordChar(0);
    m_editBox.Invalidate();
}

void CEditBoxTestDlg::OnEnKillfocusEdit1()
{
    //This 3 types also works fine
    //m_editBox.SetPasswordChar('*');
    //m_editBox.SendNotifyMessage(EM_SETPASSWORDCHAR, (WPARAM) '*', NULL);
    m_editBox.PostMessage(EM_SETPASSWORDCHAR, (WPARAM) '*', NULL);

m_editBox.Invalidate();
}

ありがとう。

于 2013-12-07T19:25:39.967 に答える