【函数】
Pie【操作系统】
Win9X:Yes
WinNT:Yes【声明】
Pie Lib "gdi32" Alias "Pie" (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【说明】 象注解里那样画一个饼图,X1,Y1,X2,Y2指定椭圆的一个约束矩形。从矩形的中心分别向X3,Y3和X4,Y4画一条线,这两条线与椭圆的交点定义了饼图占据椭圆的面积 【返回值】 Long,非零表示成功,零表示失败。会设置GetLastError 【其它】 在win95和win16中,约束矩形的宽度和高度必须在3-32766之间
参考Arc函数【参数表】
hdc ------------ Long,指定一个显示场景的句柄 X1,Y1 ---------- Long,指定椭圆约束矩形的左上角位置 X2,Y2 ---------- Long,指定椭圆约束矩形的右下角位置 X3,Y3 ---------- Long,指定饼图的一个斜边 X4,Y4 ---------- Long,指定饼图的另一个斜边 函数功能:该函数画一个由椭圆和两条半径相交闭合而成的饼状楔形图,此饼图由当前画笔画轮廓,由当前画刷填充。 函数原型:BOOL Pie(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nXRadial1, int nYRadial1, int nXRadial2, int nYRadial2); 参数: hdc:设备环境句柄。 nLeftRect:指定限定矩形左上角的X坐标。 nTopRect:指定限定矩形左上角的Y坐标。 nRigthRect:指定限定矩形右下角的X坐标。 nBottomRect:指定限定矩形右下角的Y坐标。 nXRadial1:指定第一条半径的端点的X坐标。 nYRadial1:指定第一条半径的端点的Y坐标。 nXRadial2:指定第二条半径的端点的X坐标。 nYRadial2:指定第二条半径的端点的Y坐标。 返回值:如果函数调用成功,返回值非零;如果函数调用失败,返回值是0。 Windows:要得到更多的错误信息,调用GetLastError。 备注:饼图的曲线是由符合限定矩形的椭圆定义的。曲线的起始点在椭圆与第一条半径的交点处,然后沿逆时针方向延伸,直到椭圆与第二条半径的交点处(一条半径是指从椭圆中心到椭圆上指定点之间的线段)。 函数Pie不使用和改变当前的位置。 Windows 95和Windows 98:限定矩形的坐标之和不能超过32767。nLeftRect和nRightRect之和或nTopRect和nBottomRect之和均不能超过32767。 速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:不支持;头文件:wingdi.h;库文件:gdi32.lib。Const PS_DOT = 2
Const PS_SOLID = 0
Const RGN_AND = 1
Const RGN_COPY = 5
Const RGN_OR = 2
Const RGN_XOR = 3
Const RGN_DIFF = 4
Const HS_DIAGCROSS = 5
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type LOGPEN
lopnStyle As Long
lopnWidth As POINTAPI
lopnColor As Long
End Type
Private Declare Function CreateHatchBrush Lib "gdi32" (ByVal nIndex As Long, ByVal crColor As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function CreatePenIndirect Lib "gdi32" (lpLogPen As LOGPEN) As Long
Private Declare Function CreateRectRgnIndirect Lib "gdi32" (lpRect As RECT) As Long
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function ExtractIconEx Lib "shell32.dll" Alias "ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Long, phiconLarge As Long, phiconSmall As Long, ByVal nIcons As Long) As Long
Private Declare Function FloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function FrameRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function FrameRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function InvertRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Private Declare Function OffsetRgn Lib "gdi32" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long
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 Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function RoundRect 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) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Sub Form_Load()
Me.ScaleMode = vbPixels
End Sub
Private Sub Form_Paint()
Dim hHBr As Long, R As RECT, hFRgn As Long, hRRgn As Long, hRPen As Long, LP As LOGPEN
Dim hFFBrush As Long, mIcon As Long, Cnt As Long
'Clear the form
Me.Cls
'Set the rectangle's values
SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight
'Create a new brush
hHBr = CreateHatchBrush(HS_DIAGCROSS, vbRed)
'Draw a frame
FrameRect Me.hdc, R, hHBr
'Draw a rounded rectangle
hFRgn = CreateRoundRectRgn(0, 0, Me.ScaleWidth, Me.ScaleHeight, (Me.ScaleWidth / 3) * 2, (Me.ScaleHeight / 3) * 5)
'Draw a frame
FrameRgn Me.hdc, hFRgn, hHBr, Me.ScaleWidth, Me.ScaleHeight
'Invert a region
InvertRgn Me.hdc, hFRgn
'Move our region
OffsetRgn hFRgn, 10, 10
'Create a new region
hRRgn = CreateRectRgnIndirect(R)
'Combine our two regions
CombineRgn hRRgn, hFRgn, hRRgn, RGN_XOR
'Draw a frame
FrameRgn Me.hdc, hRRgn, hHBr, Me.ScaleWidth, Me.ScaleHeight
'Crete a new pen
hRPen = CreatePen(PS_SOLID, 5, vbBlue)
'Select our pen into the form's device context and delete the old pen
DeleteObject SelectObject(Me.hdc, hRPen)
'Draw a rectangle
Rectangle Me.hdc, Me.ScaleWidth / 2 - 25, Me.ScaleHeight / 2 - 25, Me.ScaleWidth / 2 + 25, Me.ScaleHeight / 2 + 25
'Delete our pen
DeleteObject hRPen
LP.lopnStyle = PS_DOT
LP.lopnColor = vbGreen
'Create a new pen
hRPen = CreatePenIndirect(LP)
'Select our pen into the form's device context
SelectObject Me.hdc, hRPen
'Draw a rounded rectangle
RoundRect Me.hdc, Me.ScaleWidth / 2 - 25, Me.ScaleHeight / 2 - 25, Me.ScaleWidth / 2 + 25, Me.ScaleHeight / 2 + 25, 50, 50
'Create a new solid brush
hFFBrush = CreateSolidBrush(vbYellow)
'Select this brush into our form's device context
SelectObject Me.hdc, hFFBrush
'Floodfill our form
FloodFill Me.hdc, Me.ScaleWidth / 2, Me.ScaleHeight / 2, vbBlue
'Delete our brush
DeleteObject hFFBrush
'Create a new solid brush
hFFBrush = CreateSolidBrush(vbMagenta)
'Select our solid brush into our form's device context
SelectObject Me.hdc, hFFBrush
'Draw a Pie
Pie Me.hdc, Me.ScaleWidth / 2 - 15, Me.ScaleHeight / 2 - 15, Me.ScaleWidth / 2 + 15, Me.ScaleHeight / 2 + 15, 20, 20, 20, 20
'Extract icons from 'shell32.dll' and draw them on the form
For Cnt = 0 To Me.ScaleWidth / 32
ExtractIconEx "shell32.dll", Cnt, mIcon, ByVal 0&, 1
DrawIcon Me.hdc, 32 * Cnt, 0, mIcon
DestroyIcon mIcon
Next Cnt
Pie【操作系统】
Win9X:Yes
WinNT:Yes【声明】
Pie Lib "gdi32" Alias "Pie" (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【说明】 象注解里那样画一个饼图,X1,Y1,X2,Y2指定椭圆的一个约束矩形。从矩形的中心分别向X3,Y3和X4,Y4画一条线,这两条线与椭圆的交点定义了饼图占据椭圆的面积 【返回值】 Long,非零表示成功,零表示失败。会设置GetLastError 【其它】 在win95和win16中,约束矩形的宽度和高度必须在3-32766之间
参考Arc函数【参数表】
hdc ------------ Long,指定一个显示场景的句柄 X1,Y1 ---------- Long,指定椭圆约束矩形的左上角位置 X2,Y2 ---------- Long,指定椭圆约束矩形的右下角位置 X3,Y3 ---------- Long,指定饼图的一个斜边 X4,Y4 ---------- Long,指定饼图的另一个斜边 函数功能:该函数画一个由椭圆和两条半径相交闭合而成的饼状楔形图,此饼图由当前画笔画轮廓,由当前画刷填充。 函数原型:BOOL Pie(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nXRadial1, int nYRadial1, int nXRadial2, int nYRadial2); 参数: hdc:设备环境句柄。 nLeftRect:指定限定矩形左上角的X坐标。 nTopRect:指定限定矩形左上角的Y坐标。 nRigthRect:指定限定矩形右下角的X坐标。 nBottomRect:指定限定矩形右下角的Y坐标。 nXRadial1:指定第一条半径的端点的X坐标。 nYRadial1:指定第一条半径的端点的Y坐标。 nXRadial2:指定第二条半径的端点的X坐标。 nYRadial2:指定第二条半径的端点的Y坐标。 返回值:如果函数调用成功,返回值非零;如果函数调用失败,返回值是0。 Windows:要得到更多的错误信息,调用GetLastError。 备注:饼图的曲线是由符合限定矩形的椭圆定义的。曲线的起始点在椭圆与第一条半径的交点处,然后沿逆时针方向延伸,直到椭圆与第二条半径的交点处(一条半径是指从椭圆中心到椭圆上指定点之间的线段)。 函数Pie不使用和改变当前的位置。 Windows 95和Windows 98:限定矩形的坐标之和不能超过32767。nLeftRect和nRightRect之和或nTopRect和nBottomRect之和均不能超过32767。 速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:不支持;头文件:wingdi.h;库文件:gdi32.lib。Const PS_DOT = 2
Const PS_SOLID = 0
Const RGN_AND = 1
Const RGN_COPY = 5
Const RGN_OR = 2
Const RGN_XOR = 3
Const RGN_DIFF = 4
Const HS_DIAGCROSS = 5
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type LOGPEN
lopnStyle As Long
lopnWidth As POINTAPI
lopnColor As Long
End Type
Private Declare Function CreateHatchBrush Lib "gdi32" (ByVal nIndex As Long, ByVal crColor As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function CreatePenIndirect Lib "gdi32" (lpLogPen As LOGPEN) As Long
Private Declare Function CreateRectRgnIndirect Lib "gdi32" (lpRect As RECT) As Long
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function ExtractIconEx Lib "shell32.dll" Alias "ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Long, phiconLarge As Long, phiconSmall As Long, ByVal nIcons As Long) As Long
Private Declare Function FloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function FrameRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function FrameRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function InvertRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Private Declare Function OffsetRgn Lib "gdi32" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long
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 Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function RoundRect 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) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Sub Form_Load()
Me.ScaleMode = vbPixels
End Sub
Private Sub Form_Paint()
Dim hHBr As Long, R As RECT, hFRgn As Long, hRRgn As Long, hRPen As Long, LP As LOGPEN
Dim hFFBrush As Long, mIcon As Long, Cnt As Long
'Clear the form
Me.Cls
'Set the rectangle's values
SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight
'Create a new brush
hHBr = CreateHatchBrush(HS_DIAGCROSS, vbRed)
'Draw a frame
FrameRect Me.hdc, R, hHBr
'Draw a rounded rectangle
hFRgn = CreateRoundRectRgn(0, 0, Me.ScaleWidth, Me.ScaleHeight, (Me.ScaleWidth / 3) * 2, (Me.ScaleHeight / 3) * 5)
'Draw a frame
FrameRgn Me.hdc, hFRgn, hHBr, Me.ScaleWidth, Me.ScaleHeight
'Invert a region
InvertRgn Me.hdc, hFRgn
'Move our region
OffsetRgn hFRgn, 10, 10
'Create a new region
hRRgn = CreateRectRgnIndirect(R)
'Combine our two regions
CombineRgn hRRgn, hFRgn, hRRgn, RGN_XOR
'Draw a frame
FrameRgn Me.hdc, hRRgn, hHBr, Me.ScaleWidth, Me.ScaleHeight
'Crete a new pen
hRPen = CreatePen(PS_SOLID, 5, vbBlue)
'Select our pen into the form's device context and delete the old pen
DeleteObject SelectObject(Me.hdc, hRPen)
'Draw a rectangle
Rectangle Me.hdc, Me.ScaleWidth / 2 - 25, Me.ScaleHeight / 2 - 25, Me.ScaleWidth / 2 + 25, Me.ScaleHeight / 2 + 25
'Delete our pen
DeleteObject hRPen
LP.lopnStyle = PS_DOT
LP.lopnColor = vbGreen
'Create a new pen
hRPen = CreatePenIndirect(LP)
'Select our pen into the form's device context
SelectObject Me.hdc, hRPen
'Draw a rounded rectangle
RoundRect Me.hdc, Me.ScaleWidth / 2 - 25, Me.ScaleHeight / 2 - 25, Me.ScaleWidth / 2 + 25, Me.ScaleHeight / 2 + 25, 50, 50
'Create a new solid brush
hFFBrush = CreateSolidBrush(vbYellow)
'Select this brush into our form's device context
SelectObject Me.hdc, hFFBrush
'Floodfill our form
FloodFill Me.hdc, Me.ScaleWidth / 2, Me.ScaleHeight / 2, vbBlue
'Delete our brush
DeleteObject hFFBrush
'Create a new solid brush
hFFBrush = CreateSolidBrush(vbMagenta)
'Select our solid brush into our form's device context
SelectObject Me.hdc, hFFBrush
'Draw a Pie
Pie Me.hdc, Me.ScaleWidth / 2 - 15, Me.ScaleHeight / 2 - 15, Me.ScaleWidth / 2 + 15, Me.ScaleHeight / 2 + 15, 20, 20, 20, 20
'Extract icons from 'shell32.dll' and draw them on the form
For Cnt = 0 To Me.ScaleWidth / 32
ExtractIconEx "shell32.dll", Cnt, mIcon, ByVal 0&, 1
DrawIcon Me.hdc, 32 * Cnt, 0, mIcon
DestroyIcon mIcon
Next Cnt
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货