我建立一个dialog对话框程序,我在MyDlg.cpp文件中定义了一个函数void showsome();
我想在这个函数中使用 TextOut()、MoveTo()和LineTo();
请问我需要怎样做才可以做到?
我好象知道用ClassWizard生成的函数就可以直接用
CDC* pDC = GetDC();
pDC->TextOut()
pDC->MoveTo()
和pDC->LineTo();
ReleaseDC(pDC);
但在自己定义的函数中不能用CDC* pDC = GetDC();ReleaseDC(pDC);
请问我现在如何办?
急用,谢谢?

解决方案 »

  1.   

    很简单呀,你传入参数不就可以了吗?
    void showsome(CDC *pDc,...){
    pDC->TextOut()
    pDC->MoveTo()
    和pDC->LineTo();
    }
      

  2.   

    我的showsome(参数)是有参数的,我要她递归调用的,自己调用自己的,可不可以?
    谢谢
      

  3.   

    CDC *pDC = GetDC();
    pDC->TextOut
    ......
      

  4.   

    直接用API好了
    BOOL LineTo(
      HDC hdc,    // device context handle
      int nXEnd,  // x-coordinate of ending point
      int nYEnd   // y-coordinate of ending point
    );
    BOOL TextOut(
      HDC hdc,           // handle to DC
      int nXStart,       // x-coordinate of starting position
      int nYStart,       // y-coordinate of starting position
      LPCTSTR lpString,  // character string
      int cbString       // number of characters
    );
      

  5.   

    用 
    CClientDC dc(this)
    dc.TextOut()
    dc.MoveTo()
    dc.LineTo();
      

  6.   

    CClientDC dc(this)
    dc.MovoTo()
    dc.LineTo();
      

  7.   

    让函数自带一个指向CDC的指针,在执行代码中添加CDC* pDC = GetDC();pDC->TextOut(...);
    或者采用nuaawenlin(飘人) 的去做
      

  8.   

    CClient dc(this);
    dc.textout(..);
      

  9.   

    void CDlg1::OnOK() 
    {
    // TODO: Add extra validation here
    CDC* pDC=AfxGetMainWnd()->GetDC();
    pDC->TextOut(300,300,"rinima");
    AfxMessageBox("rinima");
    ReleaseDC(pDC);
    CDialog::OnOK();
    }