我使用VC++的Win32编程,现在有一个对话框,想要在上面画图,可是始终不行,我的代码如下case WM_INITDIALOG:
{
   hdc = GetDC(hwndDlg);    //hwndDlg是我的对话框句柄
   Graphics graphics(hdc);
   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawLine(&pen, 0, 0, 20, 10);
   ::ReleaseDC(hwndDlg,hdc);
}
   break;不知道是不是获取对话框的DC有问题,请有经验的大侠对对指点

解决方案 »

  1.   

    使用BeginPain/EndPaint
    怎么使用查看MSDN
      

  2.   

    可能是没有初始化GDI+库VERIFY(GdiplusStartup(&m_gdiplusToken, 
        &m_gdiplusStartupInput, NULL)==Ok);
      

  3.   

    谢谢,原来是忘了启动和关闭GDI+
    ,晕,编程编晕了,呵呵
    谢谢楼上的oyd(cpp<JavaIsNotPlatform_Independent>)(MVP)
      

  4.   

    Call GdiplusStartup before making any other GDI+ calls, and call GdiplusShutdown when you have finished using GDI+.