1.修改控件字体
m_font.CreatePointFont(100, _T("微软雅黑"));m_pEditPassword = (CEdit*)GetDlgItem(IDC_EDIT1);m_pEditPassword->SetFont(&m_font);
2.修改控件文字垂直居中
CRect rect;GetDlgItem(IDC_EDIT1)->GetClientRect(&rect);::OffsetRect(&rect, 0, 4);::SendMessage(((CEdit*)GetDlgItem(IDC_EDIT1))->m_hWnd, EM_SETRECT, 0, (LPARAM)&rect);
控件属性设置为多行
3.修改控件高度CRect rc;CWnd *pWnd = GetDlgItem(IDC_EDIT1);pWnd->GetWindowRect(&rc);ScreenToClient(&rc);rc.top += 2;rc.left += 2;rc.right -= 2;m_pEditPassword->MoveWindow(&rc);
4.设置控件为密码框
m_pEditPassword->SetPasswordChar('*');
5.响应回车
BOOL CLoginDlg::PreTranslateMessage(MSG* pMsg){ // TODO: 在此添加专用代码和/或调用基类 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) { //取得当前焦点控件的下一个控件的句柄 CWnd *mwnd = GetNextDlgTabItem(GetFocus()); if (mwnd) { mwnd->SetFocus(); //设置下一件控件得到输入焦点 return TRUE; } } return CDialogEx::PreTranslateMessage(pMsg);}
重载虚函数PreTranslateMessage