如何使用API 的PIE 和 SetBkColor 画出一个扇形?(最好是立体的)
如果哪位能把源程序发给我,200分全给他!
[email protected]

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/1743/1743742.xml?temp=.9407617
      

  2.   

    Option Explicit
    Private Declare Function Pie Lib "gdi32" (ByVal hdc As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long, ByVal x3 As Long, ByVal y3 As Long, ByVal x4 As Long, ByVal y4 As Long) As Long
    Private Const transPI = 1.74532925199433E-02
    Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Sub Command1_Click()
    drawpie Me, Me.ScaleWidth / 2, Me.ScaleHeight / 2, 100, 0, 60, vbRed
    End SubPrivate Sub Form_Load()
    Me.ScaleMode = vbPixels
    End SubPrivate Sub drawpie(mObj As Object, circleCenterPointX As Long, circleCenterPointY As Long, Radius As Long, ByVal BeginAngle As Double, ByVal EndAngle As Double, ByVal crColor As Long)
    mObj.AutoRedraw = False
    mObj.ScaleMode = vbPixels
    Dim x1 As Long, y1 As Long
    Dim x2 As Long, y2 As Long
    Dim x3 As Long, y3 As Long
    Dim x4 As Long, y4 As Long
    Dim BeginRadian As Double, EndRadian As Double
    x1 = circleCenterPointX - Radius
    y1 = circleCenterPointY - Radius
    x2 = circleCenterPointX + Radius
    y2 = circleCenterPointY + Radius
    BeginRadian = BeginAngle * transPI
    EndRadian = EndAngle * transPI
    x3 = circleCenterPointX + CLng(10000 * Math.Cos(EndRadian))
    y3 = circleCenterPointY + CLng(10000 * Math.Sin(EndRadian))
    x4 = circleCenterPointX + CLng(10000 * Math.Cos(BeginRadian))
    y4 = circleCenterPointY + CLng(10000 * Math.Sin(BeginRadian))
    Dim hBrush As Long, hOldBrush As Long
    hBrush = CreateSolidBrush(ByVal crColor)
    hOldBrush = SelectObject(mObj.hdc, hBrush)
    Pie mObj.hdc, x1, y1, x2, y2, x3, y3, x4, y4
    SelectObject mObj.hdc, hOldBrush
    DeleteObject hBrush
    End Sub