The original screen is in MemDC
I copy MemDC to MemDC2 first, then draw cross lines in MemDC2,
at last copy MemDC2 to real dc.
Why is the screen still blink when moving the mouse?
The code are in OnMouseMove
<br />
CClientDC dc(this);<br />
<br />
int OldDC=dc.SaveDC();<br />
dc.SetMapMode(MM_ANISOTROPIC);<br />
dc.SetWindowExt(m_WinXExt,-m_WinYExtTri);<br />
dc.SetViewportExt(rt.Width()-m_LeftMargin-m_DeltaViewXExt,int(rt.Height()*0.5f)-m_DescH);<br />
dc.SetWindowOrg(0,0);<br />
dc.SetViewportOrg(m_LeftMargin,int(rt.Height()*0.5f));<br />
<br />
CPoint pt(point);<br />
dc.DPtoLP(&pt);<br />
pt.x=pt.x/m_UnitsPerHemline*m_UnitsPerHemline+int(m_UnitsPerHemline*0.5f);<br />
UINT n=pt.x/m_UnitsPerHemline;<br />
if (n>=m_CntDispGrp) return;<br />
<br />
dc.LPtoDP(&pt);<br />
dc.RestoreDC(OldDC);<br />
<br />
n=m_CntCandidateGrp-m_CntDispGrp+n;<br />
m_pRs->Move(n,_variant_t(long(adBookmarkFirst)));<br />
COleDateTime OleDT=m_pRs->GetCollect("时刻");<br />
m_MemDC2.BitBlt(0,0,rt.Width(),rt.Height(),&m_MemDC,0,0,SRCCOPY);<br />
m_MemDC2.SelectObject(&m_WPen);<br />
m_MemDC2.SetROP2(R2_XORPEN);<br />
m_MemDC2.MoveTo(m_LeftMargin,point.y);<br />
m_MemDC2.LineTo(rt.Width(),point.y);<br />
m_MemDC2.MoveTo(pt.x,0);<br />
m_MemDC2.LineTo(pt.x,rt.Height()-m_BottomMargin);<br />
m_MemDC2.SetROP2(R2_COPYPEN);<br />
dc.BitBlt(0,0,rt.Width(),rt.Height(),&m_MemDC2,0,0,SRCCOPY);<br />
CBrush BBr(RGB(0,0,255));<br />
CString s=OleDT.Format();<br />
CRect RtText(0,0,0,0);<br />
m_MemDC2.SetBkMode(TRANSPARENT);<br />
m_MemDC2.SetTextColor(RGB(255,0,0));<br />
m_MemDC2.SelectObject(&m_RPen);<br />
m_MemDC2.DrawText(s,&RtText,DT_CALCRECT);<br />
RtText.InflateRect(2,0,2,0);<br />
RtText.OffsetRect(pt.x-int(RtText.Width()*0.5f),int(rt.Height()-m_BottomMargin));<br />
if (RtText.right>rt.Width()) {<br />
RtText.OffsetRect(rt.Width()-RtText.right,0);<br />
}<br />
RtText.bottom=rt.Height();<br />
RtText.top=RtText.bottom-m_BottomMargin+1;<br />
m_MemDC2.FillRect(&RtText,&BBr);<br />
m_MemDC2.DrawText(s,&RtText,DT_CENTER|DT_VCENTER|DT_SINGLELINE);<br />
m_MemDC2.MoveTo(RtText.TopLeft());<br />
m_MemDC2.LineTo(RtText.left,RtText.bottom);<br />
m_MemDC2.MoveTo(RtText.right,RtText.top);<br />
m_MemDC2.LineTo(RtText.BottomRight());<br />
<br />
float f;<br />
if (pt.y<int(rt.Height()*0.5f)) {<br />
f=m_DispMinVolt+(rt.Height()*0.5f-pt.y)*(m_DispMaxVolt-m_DispMinVolt)/(rt.Height()*0.5f-m_DescH);<br />
s.Format("%.2f",f);<br />
RtText.SetRect(0,0,0,0);<br />
m_MemDC2.DrawText(s,&RtText,DT_CALCRECT);<br />
RtText.InflateRect(0,1,0,1);<br />
RtText.right=m_LeftMargin;<br />
RtText.OffsetRect(0,pt.y-int(RtText.Height()*0.5f));<br />
if (RtText.top<0) {<br />
RtText.OffsetRect(0,-RtText.top);<br />
}<br />
m_MemDC2.FillRect(&RtText,&BBr);<br />
m_MemDC2.DrawText(s,&RtText,DT_RIGHT|DT_VCENTER|DT_SINGLELINE);<br />
m_MemDC2.MoveTo(RtText.TopLeft());<br />
m_MemDC2.LineTo(RtText.right,RtText.top);<br />
m_MemDC2.MoveTo(RtText.left,RtText.bottom);<br />
m_MemDC2.LineTo(RtText.BottomRight());<br />
} else if (pt.y<rt.Height()-int(m_BottomMargin)) {<br />
if (m_AN_ZJY==1) {<br />
f=m_DispMinAN+(rt.Height()-m_BottomMargin-pt.y)*(m_DispMaxAN-m_DispMinAN)/(rt.Height()*0.5f-m_BottomMargin-m_DescH);<br />
s.Format("%.2f",f);<br />
RtText.SetRect(0,0,0,0);<br />
m_MemDC2.DrawText(s,&RtText,DT_CALCRECT);<br />
RtText.InflateRect(0,1,0,1);<br />
RtText.right=m_LeftMargin;<br />
RtText.OffsetRect(0,pt.y-int(RtText.Height()*0.5f));<br />
m_MemDC2.FillRect(&RtText,&BBr);<br />
m_MemDC2.DrawText(s,&RtText,DT_RIGHT|DT_VCENTER|DT_SINGLELINE);<br />
m_MemDC2.MoveTo(RtText.TopLeft());<br />
m_MemDC2.LineTo(RtText.right,RtText.top);<br />
m_MemDC2.MoveTo(RtText.left,RtText.bottom);<br />
m_MemDC2.LineTo(RtText.BottomRight());<br />
} else if (m_AN_ZJY==2) {<br />
f=m_DispMinZJY+(rt.Height()-m_BottomMargin-pt.y)*(m_DispMaxZJY-m_DispMinZJY)/(rt.Height()*0.5f-m_BottomMargin-m_DescH);<br />
s.Format("%.2f",f);<br />
RtText.SetRect(0,0,0,0);<br />
m_MemDC2.DrawText(s,&RtText,DT_CALCRECT);<br />
RtText.InflateRect(0,1,0,1);<br />
RtText.right=m_LeftMargin;<br />
RtText.OffsetRect(0,pt.y-int(RtText.Height()*0.5f));<br />
m_MemDC2.FillRect(&RtText,&BBr);<br />
m_MemDC2.DrawText(s,&RtText,DT_RIGHT|DT_VCENTER|DT_SINGLELINE);<br />
m_MemDC2.MoveTo(RtText.TopLeft());<br />
m_MemDC2.LineTo(RtText.right,RtText.top);<br />
m_MemDC2.MoveTo(RtText.left,RtText.bottom);<br />
m_MemDC2.LineTo(RtText.BottomRight());<br />
}<br />
}<br />
dc.BitBlt(0,0,rt.Width(),rt.Height(),&m_MemDC2,0,0,SRCCOPY);<br />
<br />
|