问题描述
我有一些问题,谁可以提供帮助?像这样的代码:
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);
问题:
为什么有时没有显示?
谢谢
推荐答案
如果该片段在 OnPaint 处理程序,您应该使用 CPaintDC 而不是 CClientDC..如果是以 OnDraw 执行的,则应使用 CDC 参数.
If this fragment is executed inOnPaint handler, you should use CPaintDC instead ofCClientDC. If it is executed in OnDraw, you should use theCDC argument.
如果在其他地方完成,则应确保还绘制了内容 WM_PAINT 通知,即在 OnPaint 处理程序中.
If it is done in other place, you should ensure that you also draw the contents onWM_PAINT notification, i.e. in OnPaint handler.
在什么情况下绘画会失败?也许笔的宽度或坐标不正确?
这篇关于gdi +线不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!