The last effect is draw four rounded corners as shown in figure
Note: similar to the rounded rectangle
CodePudding user response:
Void CxxxxDlg: : DrawRoundFrame (CDC * pDC, CRect & amp; Clip, int diameter, int lineLen)
{
//left up
PDC - & gt; MoveTo (clip. Left + diameter/2 + lineLen, clip the top).
CPoint startLu (clip. Left + diameter/2, clip. The top).
PDC - & gt; LineTo (startLu. X, startLu. Y);
CPoint endLu (clip. Left, clip. Top + diameter/2);
CRect rcLu (clip. Left, clip. Top,
Clip. Left + diameter, clip. Top + diameter);
//pDC - & gt; SetArcDirection (AD_COUNTERCLOCKWISE);
PDC - & gt; ArcTo (& amp; RcLu startLu, endLu);
PDC - & gt; The LineTo (pDC - & gt; GetCurrentPosition (). X, clip. Left + diameter/2 + lineLen);
//left down
PDC - & gt; MoveTo (clip. Left, clip. The bottom diameter/2 - lineLen);
CPoint startLd (clip. Left, clip. The bottom diameter/2);
PDC - & gt; LineTo (startLd. X, startLd. Y);
CPoint endLd (clip. Left + diameter/2, clip, bottom);
CRect rcLd (clip. Left, clip. The bottom diameter,
Clip. Left + diameter, clip, bottom);
PDC - & gt; ArcTo (& amp; RcLd startLd, endLd);
PDC - & gt; The LineTo (pDC - & gt; GetCurrentPosition (). X + lineLen, clip, bottom);
//right down
PDC - & gt; MoveTo (clip. Right - diameter/2 - lineLen, clip, bottom);
CPoint startRd (clip. Right - diameter/2, clip, bottom);
PDC - & gt; LineTo (startRd. X, startRd. Y);
CPoint endRd (clip. Right, clip. The bottom diameter/2);
CRect rcRd (clip. Right - diameter, clip the bottom diameter,
Clip. The right + 1, clip. The bottom + 1);
PDC - & gt; ArcTo (& amp; RcRd startRd, endRd);
PDC - & gt; The LineTo (pDC - & gt; GetCurrentPosition (). X, clip. The bottom diameter/2 - lineLen);
//right up
PDC - & gt; MoveTo (clip. Right, clip. Top + diameter/2 + lineLen);
CPoint startRu (clip. Right, clip. Top + diameter/2);
PDC - & gt; LineTo (startRu. X, startRu. Y);//|
CPoint endRu (clip. Right - diameter/2, clip. The top).
CRect rcRu (clip. Right - diameter, clip the top,
Clip. Right, clip. Top + diameter);
PDC - & gt; ArcTo (& amp; RcRu startRu, endRu);
PDC - & gt; The LineTo (pDC - & gt; GetCurrentPosition (). X-ray lineLen, clip. Top);
}
Void CxxxxDlg: : OnButton1 ()
{
//TODO: Add your the control notification handler code here
CClientDC dc (this);
CRect clip (100100300300);
DrawRoundFrame (& amp; Dc, clip, 30, 20);
}
CodePudding user response:
CodePudding user response:
A straight line and arc drawn respectively