說明:
Arc 函式會在指定的裝置環境代碼(Device Context)上繪製弧線
引用函式庫:
GDI32
適用系統:
Windows NT 3.1 或 Windows 95以上
函式原型:
Declare Function Arc Lib "gdi32" Alias "Arc" ( _ ByVal hdc As Long, _ ByVal nLeftRect As Long, _ ByVal nTopRect As Long, _ ByVal nRightRect As Long, _ ByVal nBottomRect As Long, _ ByVal nXStartArc As Long, _ ByVal nYStartArc As Long, _ ByVal nXEndtArc As Long, _ ByVal nYEndtArc As Long _ ) As Long
參數型態及說明:
hdc:Long 要繪製弧形的裝置環境代碼(Device Context)
nLeftRect:Long 弧線形的左上方 X 座標
nTopRect:Long 弧線的左上方 Y 座標
nRightRect:Long 弧線的右下方 X 座標
nBottomRect:Long 弧線的右下方 Y 座標
nXStartArc:Long 弧線起始點的 X 座標
nYStartArc:Long 弧線起始點的 Y 座標
nXEndArc:Long 弧線終點的 X 座標
nYEndArc:Long 弧線終點的 Y 座標
回傳值:
Long 繪製成功的話,將會回傳非零的數值;若繪製失敗的話,則回傳 0
.NET Framework API:
System.Drawing.Graphics.DrawArc
VB範例:
檢視原始碼 Visual Basic
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 'VB的宣告 Private Declare Function Arc Lib "gdi32" ( _ ByVal hdc As Long, _ ByVal nLeftRect As Long, _ ByVal nTopRect As Long, _ ByVal nRightRect As Long, _ ByVal nBottomRect As Long, _ ByVal nXStartArc As Long, _ ByVal nYStartArc As Long, _ ByVal nXEndArc As Long, _ ByVal nYEndArc As Long _ ) As Long Private Declare Function ReleaseDC Lib "user32" ( _ ByVal hwnd As Long, _ ByVal hdc As Long _ ) As Long Private Declare Function GetDC Lib "user32" ( _ ByVal hwnd As Long _ ) As Long Dim hdc As Long '取得目前執行視窗的裝置環境代碼(Device Context) hdc = GetDC(Form1.hwnd) Dim rtvl As Long '在目前執行視窗上的(50, 50)至(200, 200)畫一個弧線 rtvl = Arc(hdc, 50, 50, 200, 200, 100, 75, 180, 180) Dim r As Long '釋放目前執行視窗的裝置環境代碼(Device Context) r = ReleaseDC(Form1.hwnd, hdc) |
RB範例:
檢視原始碼 REALBasic
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 'RB的宣告 Declare Function Arc Lib "gdi32" ( _ hdc As Integer, _ nLeftRect As Integer, _ nTopRect As Integer, _ nRightRect As Integer, _ nBottomRect As Integer, _ nXStartArc As Integer, _ nYStartArc As Integer, _ nXEndArc As Integer, _ nYEndArc As Integer _ ) As Boolean Declare Function ReleaseDC Lib "user32" ( _ hwnd As Integer, _ hdc As Integer _ ) As Integer Declare Function GetDC Lib "user32" ( _ hwnd As Integer _ ) As Integer Dim hdc As Integer '取得目前執行視窗的裝置環境代碼(Device Context) hdc = GetDC(Window1.WinHWND) Dim rtvl As Boolean '在目前執行視窗上的(0, 0)畫一個長高為100的矩形 rtvl = Arc(hdc, 50, 50, 200, 200, 100, 75, 180, 180) Dim r As Integer '釋放目前執行視窗的裝置環境代碼(Device Context) r = ReleaseDC(Window1.WinHWND, hdc) |
VB.NET範例:
檢視原始碼 VB.NET
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 'VB.NET的宣告 <DllImport("gdi32.dll")> _ Shared Function Arc( _ ByVal hdc As IntPtr, _ ByVal nLeftRect As UInteger, _ ByVal nTopRect As UInteger, _ ByVal nRightRect As UInteger, _ ByVal nBottomRect As UInteger, _ ByVal nXStartArc As UInteger, _ ByVal nYStartArc As UInteger, _ ByVal nXEndArc As UInteger, _ ByVal nYEndArc As UInteger _ ) As Boolean End Function <DllImport("user32.dll")> _ Shared Function ReleaseDC( _ ByVal hwnd As IntPtr, _ ByVal hdc As IntPtr _ ) As UInteger End Function <DllImport("user32.dll")> _ Shared Function GetDC( _ ByVal hwnd As IntPtr _ ) As IntPtr End Function Dim hdc As IntPtr '取得目前執行視窗的裝置環境代碼(Device Context) hdc = GetDC(Me.Handle) Dim rtvl As Boolean '在目前執行視窗上的(50, 50)至(200, 200)畫一個弧線 rtvl = Arc(hdc, 50, 50, 200, 200, 100, 75, 180, 180) Dim r As Integer '釋放目前執行視窗的裝置環境代碼(Device Context) r = ReleaseDC(Me.Handle, hdc) |
C#範例:
檢視原始碼 C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | //C#的宣告 [DllImport("gdi32")] public static extern bool Arc( IntPtr hdc, uint nLeftRect, uint nTopRect, uint nRightRect, uint nBottomRect, uint nXStartArc, uint nYStartArc, uint nXEndArc, uint nYEndArc ); [DllImport("user32")] public static extern uint ReleaseDC( IntPtr hwnd, IntPtr hdc ); [DllImport("user32")] public static extern IntPtr GetDC( IntPtr hwnd ); IntPtr hdc; //取得目前執行視窗的裝置環境代碼(Device Context) hdc = GetDC(this.Handle); bool rtvl; //在目前執行視窗上的(50, 50)至(200, 200)畫一個弧線 rtvl = Arc(hdc, 50, 50, 200, 200, 100, 75, 180, 180); uint r; //釋放目前執行視窗的裝置環境代碼(Device Context) r = ReleaseDC(this.Handle, hdc); |