xiaowang_hi
xiaowang_hi
2019-03-04 21:17

VC++6.0想在单文档中随机输入26个小写字母,为什么调用了TextOut却什么也没显示出来呢?

5
  • c++

更新一下自己的代码

int i = 0,j = 0;
void CWangLiuLin190304View::OnDraw(CDC* pDC)
{
    CWangLiuLin190304Doc* pDoc = GetDocument();
    if(j == 10) ::TextOut((pDC->GetSafeHdc()),0,0,"\n\r",lstrlen("\n\r"));//每10个换行
    if(i == 1)
    {
        int a;
        a = rand()%25;
        a += 'a';
        ::TextOut((pDC->GetSafeHdc()),0,0,((CString)a),lstrlen((CString)a));        
    }
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
}

两段代码

void CWangLiuLin190304View::OnBegin() 
{
    // TODO: Add your command handler code here
    SetTimer(1,500,NULL);
    i = 1;
}

void CWangLiuLin190304View::OnTimer(UINT nIDEvent) 
{
    // TODO: Add your message handler code here and/or call default
    j++;
    if(i == 1)
    {
        CDC *pDC=GetDC(); //调用OnDraw(pDC)重画 
        OnDraw(pDC);
    }
    if(j == 99) 
    {
        KillTimer(1);//100个结束
    }
    //CView::OnTimer(nIDEvent);
}

void CWangLiuLin190304View::OnEnd() 
{
    // TODO: Add your command handler code here
    i = 0;
    KillTimer(1);
}
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答