爱问知识人 爱问教育 医院库

vc 打印

首页

vc 打印

void CPreview::DrawReport(CRect rect, CDC *pDC, BOOL isprinted)
{
  titlefont.CreatePointFont(240,"宋体",pDC);
  bodyfont.CreatePointFont(120,"宋体",pDC);
  double ratex,ratey;
  if (!isprinted) //预览
  {
    ratex = 1;
    ratey = 1;
  }
  else //打印
  {
    int printx,printy;
    printx = pDC->GetDeviceCaps(LOGPIXELSX);
    printy = pDC->GetDeviceCaps(LOGPIXELSY);
    ratex = (double)(printx)/screenx;
    ratey = (double)(printy)/screeny;
    pDC->StartDoc("printinformation");
  }
  rect.DeflateRect(0,int(30*ratey),0,0);
  pDC->SelectObject(&titlefont);
  pDC->DrawText("商品表",rect,DT_CENTER);
  pDC->SelectObject(&bodyfont);
  CRect m_rect(rect);
    
  CRect temprect(m_rect.left+int(15*ratex),m_ p+int(30*ratey),
    int(15*ratex)+(m_rect.Width())/6,m_ ttom+int(300*ratey));
  CRect itemrect;
  int width = temprect.Width();
  pDC->MoveTo(int(10*ratex),int(90*ratey));
  pDC->LineTo(int(550*ratex),int(90*ratey));
  for (int i = 0;i<6;i++)
  {
    itemrect.CopyRect(temprect);    
    for (int y = 0; y< 8;y++)
    {
      itemrect.DeflateRect(0,int(40*ratey));
      pDC->DrawText(sarrays[y][i],itemrect,DT_LEFT);    
      pDC->MoveTo(int(10*ratex),int((130+y*40)*ratey));
      pDC->LineTo(int(550*ratex),int((130+y*40)*ratey));
    }
    temprect.DeflateRect(width,0,0,0);
    temprect.InflateRect(0,0,width,0);  
  }
  if (isprinted)
  {
    pDC->EndDoc();
  }
  titlefont.DeleteObject();
  bodyfont.DeleteObject();
}



其中
CRect temprect(m_rect.left+int(15*ratex),m_ p+int(30*ratey),
    int(15*ratex)+(m_rect.Width())/6,m_ ttom+int(300*ratey));
  CRect itemrect;
  int width = temprect.Width();
  pDC->MoveTo(int(10*ratex),int(90*ratey));
  pDC->LineTo(int(550*ratex),int(90*ratey));
这些语句做什么

提交回答

类似问题

换一换

相关推荐

正在加载...

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):