TA的每日心情 | 开心 2026-4-12 21:41 |
|---|
签到天数: 78 天 [LV.6]常住居民II
管理员
- 积分
- 2439
|
为了实现点击查询密码按钮,可以查看密码,2秒后,自动恢复成密码状态,使用了OnTimer定时器来实现此功能
BEGIN_MSG_MAP_EX(CBlockDlg)
MSG_WM_CREATE(OnCreate)
MSG_WM_TIMER(OnTimer)
MSG_WM_INITDIALOG(OnInitDialog)
MSG_WM_CLOSE(OnClose)
MSG_WM_SIZE(OnSize)
MSG_WM_GETDLGCODE(OnGetDlgCode)
MSG_WM_SYSCOMMAND(OnSysCommand)
CHAIN_MSG_MAP(SHostWnd)
REFLECT_NOTIFICATIONS_EX()
END_MSG_MAP()
void CModifyPasswordDlg::OnTimer(UINT_PTR cTimerID)
{
if (cTimerID == TIMER_SHOWPASSWORD1)
{
pedit_Input1->SetAttribute(L"password", L"1");
KillTimer(TIMER_SHOWPASSWORD1);
}
else if (cTimerID == TIMER_SHOWPASSWORD2)
{
pedit_Input2->SetAttribute(L"password", L"1");
KillTimer(TIMER_SHOWPASSWORD2);
}
else {
SetMsgHandled(FALSE);
}
}
通过设置是否为password的属性来显示和隐藏密码,结果定时器一直不触发,原因为了为动态检查两次密码框的内容是否一致,使用了SOUI::EventRENotify来实时响应并比较
若不相同,则”确认密码与输入不一致,请重新输入。“会显示出现,若相同则隐藏了
void CModifyPasswordDlg::OnEditNotify(SOUI::IEvtArgs* e)
{
if (!m_bHasInit)return;
SOUI::EventRENotify* e2 = SOUI::sobj_cast<SOUI::EventRENotify>(e);
if (e2->iNotify != EN_CHANGE)
return;
pedit_Input1->SetAttribute(L"password", L"0");
SOUI::SStringT sPsd1 = pedit_Input1->GetWindowText(TRUE);
pedit_Input1->SetAttribute(L"password", L"1");
pedit_Input2->SetAttribute(L"password", L"0");
SOUI::SStringT sPsd2 = pedit_Input2->GetWindowText(TRUE);
pedit_Input2->SetAttribute(L"password", L"1");
if (sPsd1 != sPsd2)
pNote->SetVisible(TRUE, TRUE);
else
pNote->SetVisible(FALSE, TRUE);
}
由于之前未加EN_CHANGE判断,导致OnTimer一直无法响应。特此记录,希望能给同样遇到此问题的人节省一点时间。
|
-
|