发表于:2003/11/26 18:51:00
#0楼
由于需要对已加载的BMP图片实现局布颜色显示,仿小画家的填充功能利用API函数对图形用局布填充。由于需要显示的地方显示有多处,我就写了一个子过程。在测试的界面上,有一个按钮,和一个picturebox(已加载了一个BMP),我的目的是,按一下按钮,系统则在按相对坐标指定点,以指定的颜色进行填充一个封闭的区域。
代码如下:在VB6.0下运行界面没有相应的变化。我不知道是哪里错了:
Public Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _
ByVal Y As Long, ByVal crColor As Long, ByVal fuFillType As Long) As Long
Private Sub StartFill(X As Long, Y As Long, Color As Long)
Dim FillPtcul As Long, Result As Long
Const FLOODFILLSURFACE = 1
Picture1.DrawStyle = vbSolid
Picture1.DrawMode = 13
Picture1.DrawWidth = 1
Picture1.FillStyle = vbFSSolid
FillPtcul = Picture1.Point(X, Y)
Picture1.FillColor = Color
Result = ExtFloodFill(Picture1.hdc, X, Y, FillPtcul, FLOODFILLSURFACE)
'Picture1.FillStyle = 1 'Default (Transparent)
Picture1.Refresh
End Sub
Private Sub Command2_Click(Index As Integer)
StartFill 2430, 3870, &H8000000F/相对坐标
End Sub
代码如下:在VB6.0下运行界面没有相应的变化。我不知道是哪里错了:
Public Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _
ByVal Y As Long, ByVal crColor As Long, ByVal fuFillType As Long) As Long
Private Sub StartFill(X As Long, Y As Long, Color As Long)
Dim FillPtcul As Long, Result As Long
Const FLOODFILLSURFACE = 1
Picture1.DrawStyle = vbSolid
Picture1.DrawMode = 13
Picture1.DrawWidth = 1
Picture1.FillStyle = vbFSSolid
FillPtcul = Picture1.Point(X, Y)
Picture1.FillColor = Color
Result = ExtFloodFill(Picture1.hdc, X, Y, FillPtcul, FLOODFILLSURFACE)
'Picture1.FillStyle = 1 'Default (Transparent)
Picture1.Refresh
End Sub
Private Sub Command2_Click(Index As Integer)
StartFill 2430, 3870, &H8000000F/相对坐标
End Sub