有一个多文档工程,当点击新建按钮后,出来一个空的文档,但是键盘无法输入(键盘事件都无法触发),却可以粘贴。
若打开一个文档,键盘就可以正常输入,这是怎么回事呢?class CSCMDoc : public CDocument
{
.....
virtual BOOL OnNewDocument();
}
BOOL CSCMDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE; // TODO: add reinitialization code here
// (SDI documents will reuse this document) return TRUE;
}
class CSCMView : public CEditView
{
...
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
}
void CSCMView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
AfxMessageBox("here");//不会出现
CEditView::OnChar(nChar, nRepCnt, nFlags);
}
若打开一个文档,键盘就可以正常输入,这是怎么回事呢?class CSCMDoc : public CDocument
{
.....
virtual BOOL OnNewDocument();
}
BOOL CSCMDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE; // TODO: add reinitialization code here
// (SDI documents will reuse this document) return TRUE;
}
class CSCMView : public CEditView
{
...
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
}
void CSCMView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
AfxMessageBox("here");//不会出现
CEditView::OnChar(nChar, nRepCnt, nFlags);
}
我在OnInitialUpdate中SetFocus(),结果还是不行,那应该在哪设置呢?多谢赐教。。void CSCMView::OnInitialUpdate()
{
CEdit& theEdit = GetEditCtrl ();
theEdit.SetFocus();//获得焦点???
theEdit.SetFont(&m_fontEdit);
.........
CEditView::OnInitialUpdate();
}