AngleArc的问题

hooligan 2000-11-04 05:53:00
我调用AngleArc画一段弧,可是怎么也画不出来,代码如下:
void CMy66View::OnDraw(CDC* pDC)
{
CMy66Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if(pDC->AngleArc(200,200,100,100,800))
{
AfxMessageBox("Success!");
}
}
谁能帮我解决?
...全文
588 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
prog_st 2001-11-20
  • 打赏
  • 举报
回复
win98 me下不支持AngleArc

HOWTO: AngleArc in Windows 3.1, Win32s, and Windows 95

Q125693


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Windows Software Development Kit (SDK) 3.1
Microsoft Win32 Application Programming Interface (API), used with:
Microsoft Win32s version 1.3
Microsoft Windows 2000 Advanced Server

--------------------------------------------------------------------------------


SUMMARY
In Windows version 3.1, Win32s, and Windows 95, you may want to use the functionality provided by the Win32 API AngleArc(). AngleArc() is only supported on Windows NT.



MORE INFORMATION
The AngleArc() function draws a line segment and an arc. The line segment is drawn from the current position to the beginning of the arc. The arc is drawn along the perimeter of a circle with the given radius and center. The length of the arc is defined by the given start and sweep angles. The starting point of the sweep is determined by measuring counterclockwise from the x-axis of the circle by the number of degrees in the start angle. The ending point is similarly located by measuring counterclockwise from the starting point by the number of degrees in the sweep angle.

The code below provides two possible ways of getting functionality similar to that of the AngleArc() function. While both of these methods will work on any Windows platform, the second (AngleArc2) will be substantially faster due to the fact that it uses the Arc() function to draw the sweep rather than calculating each of the segments on the perimeter of the arc.

NOTE: One limitation of the second method is that if the sweep angle is greater than 360 degrees, the arc will not be swept multiple times. In most cases this will not be a problem but in certain cases (constructing paths, for example) this can be a problem.

Sample Code #1

BOOL AngleArc1(HDC hdc, int X, int Y, DWORD dwRadius,

float fStartDegrees, float fSweepDegrees)

{

float fCurrentAngle; // Current angle in radians
float fStepAngle = 0.03f; // The sweep increment value in radians
float fStartRadians; // Start angle in radians
float fEndRadians; // End angle in radians
int ix, iy; // Current point on arc
float fTwoPi = 2.0f * 3.141592f;

/* Get the starting and ending angle in radians */
if (fSweepDegrees > 0.0f) {
fStartRadians = ((fStartDegrees / 360.0f) * fTwoPi);
fEndRadians = (((fStartDegrees + fSweepDegrees) / 360.0f) *
fTwoPi);
} else {
fStartRadians = (((fStartDegrees + fSweepDegrees) / 360.0f) *
fTwoPi);
fEndRadians = ((fStartDegrees / 360.0f) * fTwoPi);
}

/* Calculate the starting point for the sweep via */
/* polar -> cartesian conversion */
ix = X + (int)((float)dwRadius * (float)cos(fStartRadians));
iy = Y - (int)((float)dwRadius * (float)sin(fStartRadians));

/* Draw a line to the starting point */
LineTo(hdc, ix, iy);

/* Calculate and draw the sweep */
for (fCurrentAngle = fStartRadians;
fCurrentAngle <= fEndRadians;
fCurrentAngle += fStepAngle) {

/* Calculate the current point in the sweep via */
/* polar -> cartesian conversion */
ix = X + (int)((float)dwRadius * (float)cos(fCurrentAngle));
iy = Y - (int)((float)dwRadius * (float)sin(fCurrentAngle));

/* Draw a line segment to current point */
LineTo(hdc, ix, iy);
}

return TRUE;

}
Sample Code 2

BOOL AngleArc2(HDC hdc, int X, int Y, DWORD dwRadius,

float fStartDegrees, float fSweepDegrees)

{

int iXStart, iYStart; // End point of starting radial line.
int iXEnd, iYEnd; // End point of ending radial line.
float fStartRadians; // Start angle in radians.
float fEndRadians; // End angle in radians.
BOOL bResult; // Function result.
float fTwoPi = 2.0f * 3.141592f;

/* Get the starting and ending angle in radians. */
if (fSweepDegrees > 0.0f) {
fStartRadians = ((fStartDegrees / 360.0f) * fTwoPi);
fEndRadians = (((fStartDegrees + fSweepDegrees) / 360.0f) * fTwoPi);
} else {
fStartRadians = (((fStartDegrees + fSweepDegrees) / 360.0f) *
fTwoPi);
fEndRadians = ((fStartDegrees / 360.0f) * fTwoPi);
}

/* Calculate a point on the starting radial line via */
/* polar -> cartesian conversion. */
iXStart = X + (int)((float)dwRadius * (float)cos(fStartRadians));
iYStart = Y - (int)((float)dwRadius * (float)sin(fStartRadians));

/* Calculate a point on the ending radial line via */
/* polar -> cartesian conversion. */
iXEnd = X + (int)((float)dwRadius * (float)cos(fEndRadians));
iYEnd = Y - (int)((float)dwRadius * (float)sin(fEndRadians));

/* Draw a line to the starting point. */
if (fSweepDegrees > 0.0f)
LineTo(hdc, iXStart, iYStart);
else
LineTo(hdc, iXEnd, iYEnd);

/* Draw the arc. */
bResult = Arc(hdc, X - dwRadius, Y - dwRadius,
X + dwRadius, Y + dwRadius,
iXStart, iYStart,
iXEnd, iYEnd);

/* Move to the ending point. Arc() will not do this and ArcTo() */
/* will not work on Win32s or Win16. */
if (fSweepDegrees < 0.0f)
MoveToEx(hdc, iXStart, iYStart, NULL);
else
MoveToEx(hdc, iXEnd, iYEnd, NULL);

return bResult;

}

Additional query words:

Keywords : kbOSWin2000 kbSDKWin32 kbOSWin95 kbDSupport
Issue type : kbhowto
Technology : kbAudDeveloper kbSDKSearch kbWin32sSearch kbWin32API kbWinSDKSearch


Last Reviewed: May 11, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.




--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
bladeboy 2001-11-20
  • 打赏
  • 举报
回复
此功能仅在 Win32 模式下有效。
返回120错误
hooligan 2000-11-05
  • 打赏
  • 举报
回复
与以上两点都没关系,而且我发现我在多台98的机器上都试过了,都不出来,而我的一个同学在2000 SERVER上同样的代码就没问题,难道跟Windows有关?你们的机器上出的来吗?
另外上面代码笔误,应为:
pDC->AngleArc(200,200,100,10,80);
希望大家在自己的机器上都试一下,告诉我结果。
谢谢。
ggggwwww 2000-11-04
  • 打赏
  • 举报
回复
在OnPaint事件里写。
pDC->AngleArc(200,200,100,100,800));

Lhasa_MM 2000-11-04
  • 打赏
  • 举报
回复
是不是没有设定颜色?

16,498

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧