如何画一个圆形的分割线啊,就像时钟一样,再圆周围有刻度的。
jenes 2006-05-19 11:00:46 画圆盘和1-12刻度的函数如下所示,谢谢各位了啊
// Create a yellow pen with which we'll
// draw the ellipse.
CPen Pen( PS_SOLID, 5, RGB( 255, 255, 0 ) );
// Select the new pen into the DC and
// remember the pen that was selected out.
CPen *pOldPen = pDC->SelectObject( &Pen );
// Draw the clock face border with
// the Ellipse function.
pDC->Ellipse( 5, 5, Rect.right - 5,
Rect.bottom - 5 );
double Radians;
// Out text color will be red.
pDC->SetTextColor( RGB( 255, 0, 0 ) );
for( i=1; i<=12; i++ ){
// Format the digit CString object
// for the current clock number.
strDigits.Format( "%d", i );
// Get the text extent of the
// text so that we can center
// it about a point.
size =
pDC->GetTextExtent( strDigits,
strDigits.GetLength() );
// Calculate the number of radians
// for the current clock number.
Radians = (double) i * 6.28 / 12.0;
// Calculate the x coordinate. We
// use the text extent to center
// the text about a point.
x = nCenterX -
( size.cx / 2 ) +
(int) ( (double) ( nCenterX - 20 ) *
sin( Radians ) );
// Calculate the y coordinate. We
// use the text extent to center
// the text about a point.
y = nCenterY -
( size.cy / 2 ) -
(int) ( (double) ( nCenterY - 20 ) *
cos( Radians ) );
// Draw the text.
pDC->TextOut( x, y, strDigits );
}