CEDIT一些操作

cedit 回车窗口消失 这是因为创建窗体时 ok按钮点击了 就会出现关闭 默认回车就是这个ok按钮的事件  

只需要在 OnInitDialog 中 将焦点设置到cedit就ok 

CWnd *pWnd=GetDlgItem(IDC_EDIT1);
pWnd->SetFocus();


Cedit实现全选功能  给类添加PreTranslateMessage 事件

BOOL CJsonViewDlg::PreTranslateMessage(MSG* pMsg) 
{
// TODO: Add your specialized code here and/or call the base class
UINT  nKeyCode = pMsg->wParam; // virtual key code of the key pressed  
//实现cedit的全选功能
if (pMsg->message == WM_KEYDOWN)  
{     
if ( (nKeyCode == _T('A')) &&   
(::GetKeyState(VK_CONTROL) & 0x8000) )  
{  
CWnd *pWnd = GetFocus(); //CWnd *pWnd = GetDlgItem(IDC_EDIT1);
((CEdit*)pWnd)->SetSel(0,-1);
return(TRUE);  
}  
}  
return CDialog::PreTranslateMessage(pMsg);
}

posted @ 2014-08-20 22:44  饺子吃遍天  阅读(112)  评论(0编辑  收藏  举报