Home > Software engineering >  Dgi draws lines in the same position, draw the line does not display
Dgi draws lines in the same position, draw the line does not display

Time:10-27

I will respond to the direction key messages, didn't move, drawn to its original position, straight line color to red, but draw a straight line and did not change, want to ask next how to deal with,
Should be washed away, should be the direction key move quickly when there is a red flashing can see drawing a straight line,
The code is,
 Pen penBlack (Color: Black, 1); 
Pen penRed (Color: Red, 1);

If (m_ptHead X!=0 & amp; & M_ptHead. Y!=0 & amp; & M_ptTail X!=0 & amp; & M_ptTail. Y!=0)
{
Graphics. DrawLine (& amp; PenRed m_ptHead, m_ptTail);
}

If (m_ptHeadPre X!=0 & amp; & M_ptHeadPre. Y!=0 & amp; & M_ptTailPre X!=0 & amp; & M_ptTailPre. Y!=0)
{
Graphics. DrawLine (& amp; PenBlack m_ptHead, m_ptTail);
}

M_ptHeadPre and former m_ptTailPre is a straight line, the coordinates of the main is to draw, after will be resumed in a straight line before is black,
The following is a paint line drawing code,
 m_DrawDataLine. SetDrawPos (pt1 and pt2, m_ptHCHeadPre m_ptHCTailPre); 
M_ptHCHeadPre=pt1;
M_ptHCTailPre=pt2;
M_pGraphics m_DrawDataLine. DrawDataLine (*);

The problem is in the same position when drawing a straight line, don't show, want to ask next how to solve the great god,

CodePudding user response:

Why don't use D2D, fully supports hardware acceleration, GDI + does not support hardware acceleration, completely is not as good as GDI...

CodePudding user response:

 Pen penBlack (Color: Black, 1); 
Pen penRed (Color: Red, 1);

If (m_ptHead X!=0 & amp; & M_ptHead. Y!=0 & amp; & M_ptTail X!=0 & amp; & M_ptTail. Y!=0)
{
Graphics. DrawLine (& amp; PenRed m_ptHead, m_ptTail);
}
The else//please add this sentence?
If (m_ptHeadPre X!=0 & amp; & M_ptHeadPre. Y!=0 & amp; & M_ptTailPre X!=0 & amp; & M_ptTailPre. Y!=0)
{
Graphics. DrawLine (& amp; PenBlack m_ptHead, m_ptTail);
}
  • Related