我想在一个Dialog中在屏幕任意位置显示文字:void DrawText(int x,int y, const char* txt)
{
   这里面如何写呢?x,y 是屏幕坐标}

解决方案 »

  1.   

    CDC *pDC = GetDC(NULL);
    pDC->TextOut(x, y, txt);
    ReleaseDC(pDC);或CWindowDC dc(CWnd::GetDesktopWindow());
    dc.TextOut(x, y, txt);或
    HDC hDC = GetDC(NULL);
    TextOut(hDC, x, y, txt, strlen(txt));
    ReleaseDC(NULL, hDC);
      

  2.   

    HDC dc=::GetDesktopWindow()->GetWindowDC();
    dc->TextOut(x,y,"asdfasdf");
    但我用
    HDC dc=::GetDesktopWindow()->GetDC();
    就不行,不懂这两个得区别。
      

  3.   

    晕,试了试,居然一行就搞定CWindowDC(CWnd::GetDesktopWindow()).TextOut(10, 10, "aaaaaaaaaaa");