以下是引用xzlxzlxzl在2015-1-27 17:28:09的发言:
拓展lianyicq版主的功能,填充选中的颜色
Option Explicit
Private Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
Private Sub Form_Load()
Form1.ScaleMode = 3
Picture1.ScaleMode = 3
Picture1.AutoRedraw = True
Picture1.Circle (Picture1.Width * 0.5, Picture1.Height * 0.5), Picture1.Height * 0.4, vbRed
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim c As Long, r As Long, g As Long, b As Long, s As Integer
Randomize
r = Rnd * 255: g = Rnd * 255: b = Rnd * 255
If Button = 1 Then
c = Picture1.Point(X, Y) '获取要取代的颜色
Picture1.FillColor = RGB(r, g, b)
s = Picture1.FillStyle
Picture1.FillStyle = 0 '填充模式
ExtFloodFill Picture1.hdc, X, Y, c, 1 '从鼠标选中的点开始填充随机色(用模式1,模式0是判断边界颜色)
Picture1.FillStyle = s '还原填充模式
End If
End Sub
拓展lianyicq版主的功能,填充选中的颜色
Option Explicit
Private Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
Private Sub Form_Load()
Form1.ScaleMode = 3
Picture1.ScaleMode = 3
Picture1.AutoRedraw = True
Picture1.Circle (Picture1.Width * 0.5, Picture1.Height * 0.5), Picture1.Height * 0.4, vbRed
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim c As Long, r As Long, g As Long, b As Long, s As Integer
Randomize
r = Rnd * 255: g = Rnd * 255: b = Rnd * 255
If Button = 1 Then
c = Picture1.Point(X, Y) '获取要取代的颜色
Picture1.FillColor = RGB(r, g, b)
s = Picture1.FillStyle
Picture1.FillStyle = 0 '填充模式
ExtFloodFill Picture1.hdc, X, Y, c, 1 '从鼠标选中的点开始填充随机色(用模式1,模式0是判断边界颜色)
Picture1.FillStyle = s '还原填充模式
End If
End Sub
太感谢了,等我一句一句的读懂理解了,我就慢慢的会使用API了。
ExtFloodFill Picture1.hdc, X, Y, c, 1
这个圆在窗体上,怎么填色
[ 本帖最后由 txxb 于 2015-1-27 20:31 编辑 ]