如果你的View是:class CxxxxView : public CEditView 那么可以在:void CxxxxView::OnInitialUpdate()中调用如下的自定义函数: void CxxxxView::ShowArray(CStringArray& strArray)//准备好的字串 { CWaitCursor wait;//如果函数运行时间长 //Clean old GetEditCtrl().SetSel(0,-1); GetEditCtrl().Clear(); //Get total int rows=strArray.GetSize(); if(rows==0) return; // CString prompt; int nStartChar,nEndChar; //From start GetEditCtrl().SetSel(0,0); for(int i=0;i<rows;i++) {// Fill all prompt=strArray.ElementAt(i); GetEditCtrl().GetSel(nStartChar,nEndChar); GetEditCtrl().SetSel(nEndChar,nEndChar); GetEditCtrl().ReplaceSel(prompt); } // Otherwise you will be asked to save ... SetModify(FALSE);//ours // do not use : // GetEditCtrl().SetModify(FALSE); } // 其中:void SetModify(BOOL bModified) { m_bModified = bModified; }在类定义中.
View::OnDraw(CDC* pDC)加一句:
pDC->TextOut(1,1,"Hello ");或者在将菜单消息函数做在View中
菜单函数代码:
CDC *dc=GetDC();
dc->TextOut(1,20,"hello Menu");
那么可以在:void CxxxxView::OnInitialUpdate()中调用如下的自定义函数:
void CxxxxView::ShowArray(CStringArray& strArray)//准备好的字串
{
CWaitCursor wait;//如果函数运行时间长
//Clean old
GetEditCtrl().SetSel(0,-1);
GetEditCtrl().Clear();
//Get total
int rows=strArray.GetSize();
if(rows==0) return;
//
CString prompt;
int nStartChar,nEndChar;
//From start
GetEditCtrl().SetSel(0,0);
for(int i=0;i<rows;i++)
{// Fill all
prompt=strArray.ElementAt(i);
GetEditCtrl().GetSel(nStartChar,nEndChar);
GetEditCtrl().SetSel(nEndChar,nEndChar);
GetEditCtrl().ReplaceSel(prompt);
}
// Otherwise you will be asked to save ...
SetModify(FALSE);//ours
// do not use :
// GetEditCtrl().SetModify(FALSE);
}
//
其中:void SetModify(BOOL bModified) { m_bModified = bModified; }在类定义中.