Csimple类:public:
CPoint m_org;
vector<CPoint> m_point;
    vector<CString> m_string;void Csimple::Draw(CDC *dc)
{
    dc->SetWindowOrg(m_org);

for(vector<CString>::iterator iter=m_string.begin();iter!=m_string.end();++iter)
      dc->TextOut(m_point[iter-m_string.begin()].x,m_point[iter-m_string.begin()].y,
   *iter);
}
view类:
private:
int flag;
Csimple m_simple;
int pos;
int m_current;
//int m_cy;
TEXTMETRIC textm;
int m_totalheight;void CKeyboard2View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
dc.GetTextMetrics(&textm); //dc.SetWindowOrg(CPoint(0,pos)); CString string("OnKeyDown"),string1;
string1.Format("*** %d/////%x %d %d %d ",flag++, nChar, nRepCnt,m_current,m_totalheight);
    string+=string1;
dc.TextOut(0,m_current,string);
m_simple.m_string.push_back(string);
    m_simple.m_point.push_back(CPoint(0,m_current));
//增加变量
m_current+=textm.tmHeight+textm.tmExternalLeading;
if( m_current>=m_totalheight+pos) 
      OnVScroll(SB_LINEUP,textm.tmHeight+textm.tmExternalLeading,NULL);     
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}void CKeyboard2View::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
dc.GetTextMetrics(&textm);
      
//dc.SetWindowOrg(CPoint(0,pos));
CString string("OnKeyUp"),string1;
string1.Format("****%d//// %x %d %d %d",flag++,nChar, nRepCnt,m_current,m_totalheight);
    string+=string1;
dc.TextOut(0,m_current,string);
m_simple.m_string.push_back(string);
    m_simple.m_point.push_back(CPoint(0,m_current)); //增加变量
m_current+=textm.tmHeight+textm.tmExternalLeading;
if( m_current>=m_totalheight+pos) 
      OnVScroll(SB_LINEUP,textm.tmHeight+textm.tmExternalLeading,NULL);  
CView::OnKeyUp(nChar, nRepCnt, nFlags);
}void CKeyboard2View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
dc.GetTextMetrics(&textm);
//dc.SetWindowOrg(CPoint(0,pos)); CString string("OnChar"),string1;
string1.Format("****%d//// %c %x %d %d %d",flag++, nChar,nChar, nRepCnt,m_current,m_totalheight);
    string+=string1;
dc.TextOut(0,m_current,string);
m_simple.m_string.push_back(string);
    m_simple.m_point.push_back(CPoint(0,m_current)); //增加变量
m_current+=textm.tmHeight+textm.tmExternalLeading;
if( m_current>=m_totalheight+pos) 
      OnVScroll(SB_LINEUP,textm.tmHeight+textm.tmExternalLeading,NULL);  
CView::OnChar(nChar, nRepCnt, nFlags);
}void CKeyboard2View::OnSize(UINT nType, int cx, int cy) 
{
CView::OnSize(nType, cx, cy);

// TODO: Add your message handler code here
Invalidate();
m_totalheight=cy+pos;    CClientDC dc(this);
dc.GetTextMetrics(&textm);
}
void CKeyboard2View::OnPaint() 
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
m_simple.Draw(&dc);

// Do not call CView::OnPaint() for painting messages
}效果如下: