追加文字
int textLen = m_edit_out.GetWindowTextLengthA(); m_edit_out.SetSel(textLen, textLen); m_edit_out.ReplaceSel(str);
|
设置只读
((CEdit*)GetDlgItem(IDC_EDIT_dbName))->SetReadOnly(TRUE); ((CEdit*)GetDlgItem(IDC_EDIT_dbPwd))->SetReadOnly(TRUE);
|
获取数据
https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getdlgitemint
UINT GetDlgItemInt( HWND hDlg, int nIDDlgItem, BOOL *lpTranslated, BOOL bSigned );
|
回车事件
BOOL CDlgQueryPeople::PreTranslateMessage(MSG* pMsg) { if (WM_KEYDOWN == pMsg->message && VK_RETURN == pMsg->wParam) { if (GetFocus() == GetDlgItem(IDC_EDIT_SEARCH)) {
} }
return CDialogEx::PreTranslateMessage(pMsg); }
|
点击选中所有内容
继承CEdit
ON_WM_LBUTTONUP()
void CMyEdit::OnLButtonUp(UINT nFlags, CPoint point) { CEdit::OnLButtonUp(nFlags, point);
DWORD dw = GetSel(); UINT a, b; a = LOWORD(dw); b = HIWORD(dw); if ( a == b ) { SetSel(0,-1); } }
|