自定义一个控件,是用来画曲线的,打印曲线,最直接的是把这个控件的界面打印出来
抓图后,打印出来的却是一个对应大小的黑块
程序如下,请问问题出在哪儿呢
void CprintDlg::OnPrintCurve()
{
// TODO: 在此添加控件通知处理程序代码
    
     
CPrintDialog dlg(false);

     dlg.DoModal();  //judge the selected priter whether success to set up
 HDC hdcPrinter = dlg.GetPrinterDC();     if (hdcPrinter == NULL)
        {
          MessageBox(_T("请选择打印机!"));
         }
     else
        {
          // create a CDC and attach it to the selected printer
            CDC dcPrinter;
            dcPrinter.Attach(hdcPrinter); CDC bmpCDC;
bmpCDC.CreateCompatibleDC(mCurve.GetDC());

 
            
dcPrinter.SetMapMode(MM_ANISOTROPIC);
dcPrinter.SetBkColor(RGB(255,255,255));
dcPrinter.SetBkMode(TRANSPARENT);
    
dcPrinter.SetWindowExt(bmpCDC.GetDeviceCaps(LOGPIXELSX),bmpCDC.GetDeviceCaps(LOGPIXELSY));
            dcPrinter.SetViewportExt(dcPrinter.GetDeviceCaps(LOGPIXELSX),dcPrinter.GetDeviceCaps(LOGPIXELSY));
            
CRect CurRect;
        mCurve.GetWindowRect(CurRect); 

            //Converts device units into logical units
            bmpCDC.DPtoLP(CurRect);
        CBitmap bmp;
        bmp.CreateCompatibleBitmap(mCurve.GetDC(),CurRect.Width() ,CurRect.Height()); 

bmpCDC.SelectObject(&bmp);


DOCINFO docinfo;
            memset(&docinfo, 0, sizeof(docinfo));
            docinfo.cbSize = sizeof(docinfo);
            docinfo.lpszDocName = "曲线打印";            docinfo.lpszOutput = (LPTSTR) NULL; 
        docinfo.lpszDatatype = (LPTSTR) NULL; 
        docinfo.fwType = 0; if (dcPrinter.StartDoc(&docinfo)<0)
               {
                 MessageBox(_T("打印机初始化失败!"));
 dcPrinter.EndDoc();
               }
            else
 {
  if(dcPrinter.StartPage()<0)
  {
  MessageBox("开始页错误!");
                      dcPrinter.EndDoc(); 
  }
  else
   {
                      
                     dcPrinter.BitBlt(0,0, CurRect.Width(),CurRect.Height(),&bmpCDC,0,0, SRCCOPY); 
                     dcPrinter.EndPage();     
   }
   }
            
dcPrinter.EndDoc(); 
DeleteDC(bmpCDC);
DeleteDC(dcPrinter);
            DeleteObject(bmp); }
             
   
}