高手请教:在下面的程序中,为什么点击窗体后圆不会被颜色填充?
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 Sub Form_Click()
Me.FillStyle = 0
Me.FillColor = vbRed
FloodFill Me.hdc, 2000 / 15, 2000 / 15, vbBlue
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
Me.Circle (2000, 2000), 1000, vbBlue
End Sub
[解决办法]
几个条件,
FloodFill要用象素坐标?
要用画笔?
FloodFill中指定的x,y要显示出来?
api和AutoRedraw没关系?
Private Sub Form_Click() Dim hBrush As Long, hdc As Long hdc = GetDC(Form1.hwnd) hBrush = CreateSolidBrush(RGB(255, 0, 0)) ' 建立 brush 物件 Call SelectObject(hdc, hBrush) ' 将 brush 物件设定给 DC ' 接着再呼叫 FloodFill, 例如: Call FloodFill(hdc, Me.ScaleWidth / 2, Me.ScaleHeight / 2, RGB(0, 0, 255))End SubPrivate Sub Form_Load() Me.ScaleMode = 3 Me.AutoRedraw = True Me.Circle (Me.ScaleWidth / 2, Me.ScaleHeight / 2), IIf(Me.ScaleWidth > Me.ScaleHeight, Me.ScaleWidth / 2, Me.ScaleHeight / 2), vbBlueEnd Sub
[解决办法]
你只是画了一个圆形,当然没有被填充
你应该用画刷画