gdi +线不显示 [英] gdi+ lineto not display

查看:102
本文介绍了gdi +线不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题,谁可以提供帮助?像这样的代码:

I have some problem , who can help ? Code like :

   CClientDC hDC(m_hWnd);
    Graphics gr(hDC);
     gr.SetCompositingMode(CompositingModeSourceOver);
     gr.SetSmoothingMode(SmoothingModeAntiAlias);
     gr.SetCompositingQuality(CompositingQualityGammaCorrected);

  CClientDC hDC(m_hWnd);
    Graphics gr(hDC);
     gr.SetCompositingMode(CompositingModeSourceOver);
     gr.SetSmoothingMode(SmoothingModeAntiAlias);
     gr.SetCompositingQuality(CompositingQualityGammaCorrected);

....

r = GetRValue(m_cColorPen);
  g = GetGValue(m_cColorPen);
  b = GetBValue(m_cColorPen);

 r = GetRValue(m_cColorPen);
 g = GetGValue(m_cColorPen);
 b = GetBValue(m_cColorPen);

&Pen pen(Color(255,r,g,b),m_nPenWidth);
  pen.SetStartCap(LineCapRound);
  pen.SetEndCap(LineCapRound);

 Pen pen(Color(255, r, g, b), m_nPenWidth);
 pen.SetStartCap(LineCapRound);
 pen.SetEndCap(LineCapRound);

  CPoint pt(m_ptLast);
   CPoint ptCur(m_ptCur);
  状态nRet = gr-> DrawLine(& pen,pt.x,pt.y,ptCur.x,ptCur.y);

  CPoint pt(m_ptLast);
  CPoint ptCur(m_ptCur);
  Status nRet = gr->DrawLine(&pen, pt.x, pt.y, ptCur.x, ptCur.y);

问题:

为什么有时没有显示?

 

谢谢

 

 

推荐答案

如果该片段在 CPaintDC 而不是 OnDraw 执行的,则应使用

If this fragment is executed in OnPaint handler, you should use CPaintDC instead of CClientDC. If it is executed in OnDraw, you should use the CDC argument.

 

如果在其他地方完成,则应确保还绘制了内容 OnPaint 处理程序中.

If it is done in other place, you should ensure that you also draw the contents on WM_PAINT notification, i.e. in OnPaint handler.

 

在什么情况下绘画会失败?也许笔的宽度或坐标不正确?


这篇关于gdi +线不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆