达拉然怎么能跑进去:运用VB方法给指定区域填充颜色

来源:百度文库 编辑:高考问答 时间:2024/05/09 14:05:46

可以这样解决。我指定的区域就是form1区域。

在vb6下调试通过:

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 FloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim hBrush As Long, hOldBrush As Long

hBrush = CreateSolidBrush(RGB(255, 0, 0))

hOldBrush = SelectObject(Me.hdc, hBrush)
FloodFill Me.hdc, X, Y, RGB(0, 0, 0)
SelectObject Me.hdc, hOldBrush
DeleteObject hBrush
End Sub